How to get linear_velocity from a spatial node?

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

I am trying to get my planes linear velocity but i’m getting the error "Invalid get index ‘linear_velocity’ (on base: ‘Spatial (Plane.gd)’.

my plane’s variable is:

onready var target: Spatial = get_node(target_path)

(target path goes to the planes spatial node)

And here’s the line that breaks:

var target_velocity = target.linear_velocity

I’m pretty new to gdscript so help is much appriciated and it might just be something very simple that im missing :slight_smile:

A Spatial node doesn’t have the linear_velocity property; only a RigidBody node has the linear_velocity property.

Ertain | 2022-02-10 06:30

:bust_in_silhouette: Reply From: mneg

I think Ertain gave the answer: velocities and other physics based parameters are unknown to Spatial. You would need to query the child RigidBody for that or if none available start using them for your physics.