playMaker

Author Topic: Drag Constrain/clamp[SOLVED]  (Read 1127 times)

TerraImagina

  • Playmaker Newbie
  • *
  • Posts: 33
Drag Constrain/clamp[SOLVED]
« on: February 06, 2020, 06:03:17 AM »
Hello,

I want to be able to drag an object to a constraint area only.

I have been following this awesome tutorial about touch control with playmaker,
There is an example that allow to drag an object with touch.
I have been trying to modificate it to constrain or clamp the movement to certain area, but without success...
This exemple use a translate action to move the object, with variable touchXdelta and touchYdelta that come from GetTouchInfo action.
I tried using a float clamp on those variable to constrain them, before the translate action, but the result is not working as intended.
Does it work to use float clamp for a translate action ? Is there another way to constrain a drag object?

Thank you!
« Last Edit: February 08, 2020, 03:55:25 AM by djaydino »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Drag Constrain/clamp
« Reply #1 on: February 06, 2020, 07:29:28 AM »
Hi,

 this gives a good demonstration of how it can be done:

https://answers.unity.com/questions/633457/limiting-game-object-position-by-rect.html

have you checked the "Move towards with constraint" sample on the ecosystem?

Bye,

 Jean

TerraImagina

  • Playmaker Newbie
  • *
  • Posts: 33
Re: Drag Constrain/clamp
« Reply #2 on: February 07, 2020, 12:34:54 PM »
Hi JeanFabre

The "Move towards with constraint" sample was exactly what I was looking. Now I understand the logic of how the constrain is working.

Thank you!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Drag Constrain/clamp[SOLVED]
« Reply #3 on: February 10, 2020, 01:05:48 AM »
Hi,

 great!

Bye,

 Jean