constraint x position with a margin
hey there everyone!
I would like to constraint my actor x position when he overlaps or colide with a transport platform....
The actor x position is constrained by the platform x position, so when the platform is moving, the actor move with and don't fall....
But the problem is i can't move the actor from left to right when i'm inside the platform because his x position is constrained to the x position of the platform, so i would like to do this same operation, but with a little margin, so the actor can move from left to right of the plaftorm but without falling....
Is this posible???
thanks a lot!
I would like to constraint my actor x position when he overlaps or colide with a transport platform....
The actor x position is constrained by the platform x position, so when the platform is moving, the actor move with and don't fall....
But the problem is i can't move the actor from left to right when i'm inside the platform because his x position is constrained to the x position of the platform, so i would like to do this same operation, but with a little margin, so the actor can move from left to right of the plaftorm but without falling....
Is this posible???
thanks a lot!
Comments
I know i need to use the max min function, but i don't know how, anyone can help me please?
I will tell how to do because maybe it can help somebody.
Constrain x position two times, one with max function and another one with min function.
Supose your platform width is 100, then the first constrain would be:
constraint self.xPosition to max(self.xposition, game.plaftformXposition -50)
the second constraint would be:
constraint self.xPosition to min(self.xposition, game.plaftformXposition +50)
the actor can now move over the moving platform but never fall.
cheers!
I could be wrong, but I think this will still work, and will increase performance.