Changing Rigidbody Velocity

Godot Version

4.3.1

Question

Hello,

I’m trying to modify a rigidbody’s y-velocity in a different script. I came across _integrate_forces(), but from what I can tell you have to use a script attached to each rigidbody to use that. I also tried using the _add_force(vec3, vec3) function rigidbodies have, but I got an error saying the function did not exist.

Is there another way to go about change a rigidbody’s velocity in a different script that isn’t attached to it?

Something like:

var rigidbody = $"here/there/rigidbody3d"

var _process(delta):
      rigidbody.set_velocity(vec3(0,.1,0)

Thanks

Nevermind, turns out it was just a simple parameter.

This is the solution:

func _physics_process(delta: float) -> void:
	var rigid = $"../path/RigidBody3D"
	rigid.linear_velocity.y = rigid.linear_velocity.y + 10*delta
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.