Make Rigidbody3d move in the direction it's facing

Godot Version

v4.3.stable.steam [77dcf97d8]

Question

How do I make a RigidBody3d move in the direction it’s facing? All I can find online either is specific to a user’s case, or uses transform.x, which doesn’t seem to work in the current version.

I’m pretty sure it’s just.

apply_central_force(-global_transform.basis.z*FORCE)

Or whichever basis axis your model face is. -z is considered forward for Vector3.FORWARD constant.

I got a “Function “apply_central_force()” not found in base self” error

apply_central_force() takes a Vector3 as a parameter. It looks like your code is sending in the z coordinate only.

Untested, but try…

var force: Vector3 = Vector3(0, 0, -global_transform.basis.z*FORCE)
apple_central_force(force)

This is a function for rigidbodies, if it doesn’t exist then you may not be working with a rigid body

Ah, I figured it out. I was applying code to the parent node that hosts the rigidbody, not the rigidbody itself.

Basis.z is a vector

Nevermind, still the same error.

Damnit, I forgot to change the “extends”

It’s not forces that I want though, I want it to simply move towards the player, not launch itself.