how to teleport a kinematic body 2d

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

I have just started making my own version of Flappy Bird. For the logic, I have the bird which is a kinematic body in the center of the screen. I want to pipes to come from the
left of the screen and go out from right. I want to find a way to teleport the pipes from the left of the screen to the right by changing the coordinates of it. How can I do this in gdscript?

:bust_in_silhouette: Reply From: kidscancode

Just to make sure, since you said two opposite things. You want the pipe to start at the left, move across the screen, and then teleport from the right back to the left. Correct?

You just need to set the body’s position property. For example:

if position.x > screen_size.x:
    position.x = 0

If it was the opposition you wanted, reverse the above.