Using X position to stop a force

Hi guys,
I am doing a simple test to animate objects, but I ran into a problem. When checking if the object has reached a certain position (left side of the screen) and make it stop, it won’t work. What am I doing wrongP

Cheers

Farid

Hi Farid, try: the x position < 0 .

Permanent force maybe can not be stopped, you should try with instant force or add an object to check collision to for instance add blockTrender so later you check
if Trender is in collision with blockTrender
Stop Trender (remove all forces)

Instant force does not work with the button was released event as intended. The solution I suggested works, but adding a collision object does too.

Other option is to add a bool variable to Trender like isMoving = false
So when you create the Trender set that variable to true

in another event just check if isMoving = true
Apply instant force to X…

and in another event
if X of Trender <= 0 or wherever number you want.
isMoving = false
Stop Trender…

Thanks guys,
I tried Dronas advise ( x position > 0 ) and it worked fine. Meanwhile I also put a tweening behaviour on the object and that also worked fine and with the easeOut option it was really good.

Cheers

Farid

1 Like