playMaker

Author Topic: How to detect when creature can't move forward?  (Read 3905 times)

amaranth

  • Full Member
  • ***
  • Posts: 172
How to detect when creature can't move forward?
« 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


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to detect when creature can't move forward?
« Reply #1 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

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: How to detect when creature can't move forward?
« Reply #2 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.


Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: How to detect when creature can't move forward?
« Reply #3 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...

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: How to detect when creature can't move forward?
« Reply #4 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?



« Last Edit: March 29, 2012, 02:47:22 PM by amaranth »

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: How to detect when creature can't move forward?
« Reply #5 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

justifun

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 280
Re: How to detect when creature can't move forward?
« Reply #6 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!

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: How to detect when creature can't move forward?
« Reply #7 on: March 29, 2012, 02:52:57 PM »
Thank you! Hehehe, using playMaker is almost too much fun! :D