playMaker

Author Topic: Set constraint for object position?  (Read 2092 times)

SawyerK

  • Junior Playmaker
  • **
  • Posts: 99
Set constraint for object position?
« on: July 15, 2020, 09:36:48 AM »
Hi!
I have an FSM where i move an object up/down by turning another object by mousewheel rotation. My question is how can is set a constraint for the up/down moving object?



djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Set constraint for object position?
« Reply #1 on: July 15, 2020, 11:20:14 AM »
Hi.
You can Check The Y position with a float compare.

if Greater or equal go to a state (top) And check if the next scroll is positive or negative
if for example negative it can go back to the Rotating but before it goes back you need to set the Y pos a little bit lower than the comparison.
If positive, do nothing.

also check for lower than (bottom)
and if equal or less go to a different state and do the same as on the 'top' but then positive can go back to the rotation state.

or use a float clamp, but then you could still do the rotation on the handle.

SawyerK

  • Junior Playmaker
  • **
  • Posts: 99
Re: Set constraint for object position?
« Reply #2 on: July 16, 2020, 06:20:14 AM »
Thank you for your answer!
Where do i use float clamp? Because the only float this FSM has is the scroll itself, which is only used when the mousewheel is turned (+20, -20) i cant clamp that.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Set constraint for object position?
« Reply #3 on: July 16, 2020, 07:06:26 AM »
Hi.
Actually clamp would not work in this setup.

Best is to check the position of the window.

And if top/bottom reached limit the rotation to 1 direction.

For this you could use a clamp,
For example if top reached set min to -20 and max to 0
if bottom reached Set min to 0 and max to 20
if somewhere in between set min to -20 and max to 20

you can do the position check on a different fsm and use Set Fsm Float To set the Min and Max on the Clamp variables