How do I get a Node´s velocity

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Elias
 initVelocity = self.velocity 
finalVelocity = RAWAcceleration * delta + initVelocity

here i´m trying to get the velocity of a kinematic body with self.velocity Is this the way to go?

I get the error message: Invalid get index "velocity" (on base: "KinematicBody(KinematicBody.gd)").

:bust_in_silhouette: Reply From: kidscancode

A KinematicBody doesn’t have a velocity property. Kinematic bodies only move based on your code, so you must provide a velocity and implement movement yourself.

See Using KinematicBody2D for details.

Ok, thanks. Are there any nodes that have a velocity property?

Elias | 2018-10-28 08:25

RigidBody2D is a node with a physics that is calculated by the engine. It has a linear_velocity but you can’t set it directly. There is information about it here: Physics Introduction

kidscancode | 2018-10-28 18:34