Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: amaranth on March 28, 2012, 10:39:31 PM

Title: How to detect when creature can't move forward?
Post by: amaranth on March 28, 2012, 10:39:31 PM
For my 2D platformer...

I've got a creature that moves back and forth in a cavern. When it touches the wall and can't move, it needs to turn around and walk the other way.

Right now, the creature walks across the cavern, but when it gets to the wall, it stops. I can't seem to get it to turn around.

To get my creature to walk left or right, I've used Controller Simple Move to specify an X coordinate (100 or -100).

Please help. :S

Title: Re: How to detect when creature can't move forward?
Post by: jeanfabre on March 29, 2012, 04:09:51 AM
Hi,

 simply react to the trigger Event or Collisions Event and change your coordinates ( multiply by -1 and reinject or modify the move to command)

What are the things you tried so far?

Bye,

 Jean
Title: Re: How to detect when creature can't move forward?
Post by: amaranth on March 29, 2012, 12:45:52 PM
I tried using Collision Event, but when I did this, the collision event was triggered each time my creature moved across the ground. Here's an image to show you the logic attached to my ground terrain. When I push the play button, the slime drops down and randomly moves left or right until something blocks it's movement.

(http://i781.photobucket.com/albums/yy94/agf8623/slime-world.png)
Title: Re: How to detect when creature can't move forward?
Post by: Alex Chouls on March 29, 2012, 01:48:22 PM
Try Get Controller Collision Flags. This gives you more info about the type of collision.

I'll make a Character Collision Event version of that action so you don't need a second action to test the flag.

Or you could set up "feeler" collision boxes around your character, and use those to send events...
Title: Re: How to detect when creature can't move forward?
Post by: amaranth on March 29, 2012, 02:45:28 PM
Worked beautifully! Now for my next question... I need my slime to traverse over small hills. The terrain in my game won't be perfectly flat. The collision flag works great, but is there an action that can track whether the controller is not moving at all?

(http://i781.photobucket.com/albums/yy94/agf8623/collision-check-fsm.png)

Title: Re: How to detect when creature can't move forward?
Post by: justifun on March 29, 2012, 02:47:59 PM
You can use the action "get gameobject speed"

http://hutonggames.com/playmakerforum/index.php?topic=1182.0

this will tell you how fast an object is moving

then float compare to 0 to determine if its stopped moving
Title: Re: How to detect when creature can't move forward?
Post by: justifun on March 29, 2012, 02:48:34 PM
Try Get Controller Collision Flags. This gives you more info about the type of collision.

I'll make a Character Collision Event version of that action so you don't need a second action to test the flag.

Or you could set up "feeler" collision boxes around your character, and use those to send events...

Wicked, i was trying to figure out a good way to determine if something fell on my characters head.  This should work great. thx alex!
Title: Re: How to detect when creature can't move forward?
Post by: amaranth on March 29, 2012, 02:52:57 PM
Thank you! Hehehe, using playMaker is almost too much fun! :D