How can I get the Vector2 () value for RigidBody2D?

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

How can I get the Vector2 () value for RigidBody2D?

func _on_Zona_body_entered(body):
apply_impulse(Vector2(),body.position*30)
:bust_in_silhouette: Reply From: jgodfrey

Not sure what Vector2 you’re after - I assume the position? If that’s the case you get it just like any node that inherits from Node2D - via its position property.

So…

$RigidBody2D.position # - position relative to its parent
$RididBody2D.global_position # - global position

I did not indicate one nuno thing. I have such a code, and it is necessary that with the help of a pulse one RigidBody 2D move to another.

func _on_Zona_body_entered(body):
apply_impulse(Vector2(),body.position*30)

Korsut | 2020-04-26 17:44