playMaker

Author Topic: How do I make a magnet powerup FSM? [SOLVED]  (Read 302 times)

Neikke

  • Junior Playmaker
  • **
  • Posts: 53
    • View Profile
How do I make a magnet powerup FSM? [SOLVED]
« on: October 04, 2017, 02:59:54 AM »
Hi,

I've bought PLaymaker a few days ago and watched beginner videos but still kind of unsure how would I approach the following. I develop some generic auntorunner side scroller type of game, and the only thing is left - is adding powerups like magnet, shields score doubles etc.

I already have coins properly set up, I mean I can "collect" them, they disappear after colliding with them etc. But how do I set up a magnet? I would highly appreciate any help and advice on this matter!  Thanks in advance!
« Last Edit: October 08, 2017, 07:45:43 PM by djaydino »

krmko

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
    • Fat Pug Studio
Re: How do I make a magnet powerup FSM?
« Reply #1 on: October 04, 2017, 03:25:18 AM »
Coin should have FSM which checks if there's a magnet on the player. If there is, in the next state put move towards action and set player as target.

If you want some magnet range distance shenanigans, you can set another state between those two that checks distance and jumps to move towards state when player is in range, and goes back to previous state when it is not. Check is done every frame of course. You can even set a variable for move towards speed with add float so it accelerates towards player and resets itself with set float 0 when player goes out of range.
« Last Edit: October 04, 2017, 03:27:14 AM by krmko »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2288
    • View Profile
    • jinxtergames
Re: How do I make a magnet powerup FSM?
« Reply #2 on: October 04, 2017, 10:16:19 PM »
Hi,
I made a sample video they i would do this and will make a tutorial from it later on


Let me know if its good or not :)
« Last Edit: October 04, 2017, 10:18:13 PM by djaydino »

Neikke

  • Junior Playmaker
  • **
  • Posts: 53
    • View Profile
Re: How do I make a magnet powerup FSM?
« Reply #3 on: October 05, 2017, 05:28:52 PM »
Coin should have FSM which checks if there's a magnet on the player. If there is, in the next state put move towards action and set player as target.

If you want some magnet range distance shenanigans, you can set another state between those two that checks distance and jumps to move towards state when player is in range, and goes back to previous state when it is not. Check is done every frame of course. You can even set a variable for move towards speed with add float so it accelerates towards player and resets itself with set float 0 when player goes out of range.

This sounds very good! The things is I'm only starting to learn Playmaker, and I'm not familiar with its toolset very well, I mean which actions to use when etc. So in theory it looks awesome for me, but unfortunately can't imagine how to achieve it yet. If you'd have time to go a bit more in detail how to do this check for coins to return - that would be great! Thanks a lot for your reply - I slowly start to understand the mechanics behind it!

Hi,
I made a sample video they i would do this and will make a tutorial from it later on


Let me know if its good or not :)

That's just awesome! Thank you so much for your effort and making a video! There are a few minor dark parts for me there but I think I will just do it step by step as you showed and will understand the purpose of some actions better!

Also, I wanted to ask, how would you approach this task if it wasn't a button to turn magnet on and off but if it was a magnet as Powerup in a level which player earns by colliding with it? As I understand it, I would create a magnet, with a collider with On trigger Enter state, which would send an event to activate magnet. Then I would probably need to have some timer to not let player have magnet forever but for, let's say, 10 seconds, and then deactivate. But.. how to actually do it, which nodes/actions house - a bit dark for me. If you'd be so kind to clear this up for me - I would highly appreciate that! And again - thanks a lot man for the video man!
« Last Edit: October 05, 2017, 05:30:40 PM by Neikke »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2288
    • View Profile
    • jinxtergames
Re: How do I make a magnet powerup FSM?
« Reply #4 on: October 05, 2017, 08:23:48 PM »
Hi,
on the player have a addition trigger event action but set the tag to magnet,
then set a event (magnetCollected for example)

then activate the magnet fsm.

on the magnet fsm if you use my provided action you can use a wait there and set an event for the next state, on the next state you can disable the fsm

Then instead of disable/enable, Set it up like on this picture and use a send event to activate the magnet.



here is a video on how to use Global transitions :


Neikke

  • Junior Playmaker
  • **
  • Posts: 53
    • View Profile
Re: How do I make a magnet powerup FSM?
« Reply #5 on: October 06, 2017, 12:35:56 PM »
Thanks djaydino! I've watched your video and tried to recreate it accurately but for some reason my player won't collect any coins at all. I've sent you PM with the download link, can you please check it? 

krmko

  • Sr. Member
  • ****
  • Posts: 422
    • View Profile
    • Fat Pug Studio
Re: How do I make a magnet powerup FSM?
« Reply #6 on: October 06, 2017, 02:29:44 PM »
I'll send you the screenshot how should it look.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2288
    • View Profile
    • jinxtergames
Re: How do I make a magnet powerup FSM?
« Reply #7 on: October 07, 2017, 03:14:44 AM »
Hi,
did you set a tag on the coin objects?



Neikke

  • Junior Playmaker
  • **
  • Posts: 53
    • View Profile
Re: How do I make a magnet powerup FSM?
« Reply #8 on: October 07, 2017, 02:24:32 PM »
Hi,
did you set a tag on the coin objects?




Yes I did!

Neikke

  • Junior Playmaker
  • **
  • Posts: 53
    • View Profile
Re: How do I make a magnet powerup FSM?
« Reply #9 on: October 07, 2017, 03:30:25 PM »
Also what I don't understand, where this "target" comes form? is it some global variable or..?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 2288
    • View Profile
    • jinxtergames
Re: How do I make a magnet powerup FSM?
« Reply #10 on: October 07, 2017, 07:35:54 PM »
Hi,
You get the target in the trigger state, with the 'trigger action' on "Store Collider".

It stores the object that went inside the trigger.

Neikke

  • Junior Playmaker
  • **
  • Posts: 53
    • View Profile
Re: How do I make a magnet powerup FSM?
« Reply #11 on: October 08, 2017, 04:12:38 AM »
Hi,
You get the target in the trigger state, with the 'trigger action' on "Store Collider".

It stores the object that went inside the trigger.

Got it! Thanks a lot Dino!