0 votes

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

func _on_Zona_body_entered(body):
apply_impulse(Vector2(),body.position*30)
in Engine by (42 points)
edited by

1 Answer

+1 vote
Best answer

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
by (10,914 points)
selected by

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)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.