Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Lcs-lts |
so I’m learning Godot, and now I’m trying to get the distance (in pixels, meters, whatever) between the player and a rigidbody. Just like in this question, but in 3D.
I’m trying to apply_impulse to this rigidbody, but the impulse should be divided by the distance between them.
It’s the same distance_to
Magso | 2020-09-25 23:42
i’m trying this:
var distance = get_node(".").distance_to(body)
“body” is because I’m comparing to the body that entered in the area*
but it throws a invalid call, NonExistent Function in base KinematicBody.
any idea?
Lcs-lts | 2020-09-26 01:27
the distance_to function only works on Vector3s, so if you try:
var distance = get_node(".").translation.distance_to(body.translation)
that should hopefully work
RedBlueCarrots | 2020-09-26 01:46