Moving Object

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LuisGames987

Everytime I try to make an object stop in specifics coordinates, they go way more than i expect, how to I make them stop in a specific Y coordinate??

You should show what you have tried. It will help to see what you may be doing wrong.

kidscancode | 2020-02-08 22:12

:bust_in_silhouette: Reply From: Sween123

Using an if statement. When your current coordinate is close enough to the specific target coord, set its position to it.
Let’s say you have variables SPEED_X, SPEED_Y, TARGET_POSITION
if abs(TARGET_POSITION.x - object.position.x) < abs(SPEED_X) and abs(TARGET_POSITION.y - object.position.y) < abs(SPEED_Y):
object.set_postion(TARGET_POSITION)
object.target_position_reached()