playMaker

Author Topic: Help using "Move Towards" with Constraints  (Read 1195 times)

vivifx

  • Playmaker Newbie
  • *
  • Posts: 2
Help using "Move Towards" with Constraints
« on: October 02, 2022, 09:19:28 PM »
Hello All!

I am trying to make an object follow the player within constraints.  I have a 2D Sprite of a pupil within an eye, and I am trying to make it rotate towards the player as they walk by it on screen as well as move towards the player - as long as it is within the bounds of the eye. When it reaches the edge of the eye it should stop there and then only move again if its going back the other way (ie the player walks past it so now it's moving a different direction)

I've got the first bit of the functionality down with the "Look At" Action - there is a great tutorial for this. However second bit is tricky.

"Move Towards" with a "Clamp" seems like it would be the best, but I can't figure out how to clamp or constrain that movement in any way. Move towards seems to ignore it.

"Move Towards" also ends after reaching the max distance. I was also considering collisions to bound the pupil within the eye, but Move Towards doesn't seem to be respecting my collision boundaries 

Any thoughts? I'm relatively new to playmaker so forgive me if this is something very simply solved!

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Help using "Move Towards" with Constraints
« Reply #1 on: October 03, 2022, 12:34:09 PM »
Hi.
Move toward uses translate i believe and this will not work with physics.

maybe check position and if (for example) greater than 10 stop move (go to 'right end state')
in 'right end state' check player position, if less than x pos
start moving again.

and for left side the same thing but the if less than -10 and greater than x pos

vivifx

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Help using "Move Towards" with Constraints
« Reply #2 on: October 06, 2022, 04:39:38 PM »
Yep that did it! Thank you @djaydino.

Also good tip on Move Towards now working with physics, I'll keep that in mind for the future!