playMaker

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

amaranth

  • Full Member
  • ***
  • Posts: 172
    • View Profile
How to detect when creature can't move forward?
« on: March 28, 2012, 07: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: 14316
  • Official Playmaker Support
    • View Profile
Re: How to detect when creature can't move forward?
« Reply #1 on: March 29, 2012, 01: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
    • View Profile
Re: How to detect when creature can't move forward?
« Reply #2 on: March 29, 2012, 09:45:52 AM »
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: 3627
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: How to detect when creature can't move forward?
« Reply #3 on: March 29, 2012, 10:48:22 AM »
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
    • View Profile
Re: How to detect when creature can't move forward?
« Reply #4 on: March 29, 2012, 11:45:28 AM »
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, 11:47:22 AM by amaranth »

justifun

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 228
    • View Profile
Re: How to detect when creature can't move forward?
« Reply #5 on: March 29, 2012, 11:47:59 AM »
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
  • Full Member
  • *
  • Posts: 228
    • View Profile
Re: How to detect when creature can't move forward?
« Reply #6 on: March 29, 2012, 11:48:34 AM »
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
    • View Profile
Re: How to detect when creature can't move forward?
« Reply #7 on: March 29, 2012, 11:52:57 AM »
Thank you! Hehehe, using playMaker is almost too much fun! :D