playMaker

Author Topic: limiting objects movement  (Read 3657 times)

mortos360

  • Playmaker Newbie
  • *
  • Posts: 2
limiting objects movement
« on: March 23, 2014, 02:39:11 PM »
Hallo,
I have following problem:

I want to move an object between point "a" and point "b" (simple linear axis) in space, which works fine so far. I am getting the mouse position, setting it to zero and then feed the change as translation for the object. So when you move mouse to the left, the object goes left... you move to right, the object goes right. The further away the mouse is from zero, the faster the object moves. All that works fine, but I can't find a way to limit the objects movement.
I need to be abel to stop the object from moving after some distance. Imagine a simple slider interface for volume, or something else.. it can only move between 2 points. Once it reaches his limit, he needs to stop there, but still be abel to move back if the user pulls the mouse in the opposite direction.

I think the main problem is that I am not using Set Position, instead I am using Translate, which is works perfect for what I want... I just have that limiting problem. Maybe someone can give me a hint how to fix that.

Thanks!

 
« Last Edit: March 23, 2014, 02:45:16 PM by mortos360 »

MrMitch

  • Full Member
  • ***
  • Posts: 131
    • Rage Quit Games - Coming Soon
Re: limiting objects movement
« Reply #1 on: March 23, 2014, 06:33:11 PM »
I think Float Clamp will allow you to do this or any Clamp depending on what variables you're working with.

mortos360

  • Playmaker Newbie
  • *
  • Posts: 2
Re: limiting objects movement
« Reply #2 on: March 23, 2014, 06:42:08 PM »
Thanks for the answer!!
I though that too.. but I can't seem to find a way how to implement that!

It would be easier if I would use the Set Position command, then I would work with real position values, but since I am using Translate... there is no way (at least I don't see it) to use clamp function.

Remember, I am feeding the mouse value into a translation node.. and I would like to keep it that way if possible since it behaves exactly like I want.


MrMitch

  • Full Member
  • ***
  • Posts: 131
    • Rage Quit Games - Coming Soon
Re: limiting objects movement
« Reply #3 on: March 24, 2014, 09:25:07 AM »
If you could post a picture of your setup so i can see how things are working.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: limiting objects movement
« Reply #4 on: July 17, 2014, 02:02:04 PM »
Hi,

 Sorry old post, but going through back log ( yes it goes as far as march... ouch).

Have you studied the M2H samples, there is a limiter in there and you could inspire from that for your system.

https://hutonggames.fogbugz.com/default.asp?W882

Study that. The other pretty simple alternative is to turn your object into a rigibody, use add force and have two colliders where your limits are, it's the best and quickest way with physics ( and you can constraint your physics GO to only be able to translate on that axis for example).


Bye,

 Jean