How to teleport a Kinematic Body 2D from place A to B

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

how it is possible to move a kinemtic Body 2D from point A to B, if it for example touching a wall or somthing like that.

:bust_in_silhouette: Reply From: simonmakesgoodgames


Once you find the trigger for moving a kinematic body to point b, just open the script for your kinematic body and do

position = Vector2(xxxx, yyyy)

You can also make point B a variable, like

var point_B = Vector2(100, 200)
position = point_B

so you can change where point b is at any time, like at the press of a button

func _on_SomeRandomButton_pressed():
     point_B = point_B + Vector2(50, 50)


position = point_B

Thanks for the quick answer :slight_smile:

Nils | 2019-11-25 15:59

:bust_in_silhouette: Reply From: Dlean Jeans


body.position = new_position

Thanks for the quick answer :slight_smile:

Nils | 2019-11-25 14:49