![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | PrecisionRender |
I have used Godot for over a year at this point. It’s my favorite engine and I’m eagerly waiting for Godot 4 like most!
My issue is that I’m trying to get linear_velocity
in a RigidBody3D, and get the local z component of that. Without it being local, the z component will not represent the forward force. I just want to get the forward force of the rigidbody. In Godot 3.X, we’d use transform.basis.xform_inv(linear_velocty)
, but it appears this method has been removed entirely from Basis in Godot 4. Here is my code:
extends RigidBody3D
var real_speed : float = 0
func set_inputs(vertical : float, horizontal : float):
pass
func _physics_process(delta):
linear_velocity = transform.basis.z * -20
rotate_y(0.02)
func _integrate_forces(state):
real_speed = linear_velocity.z
print_debug(real_speed)
Is there a method that I don’t know about in the new API? Thanks in advance!
Edit: There seems to be a Transform2D method for basis_xform()
and basis_xform_inv()
. I wonder why a 3D version doesn’t exist…
Second Edit: Hmm. In the Transform3D header file, there is an implementation of this method. So why isn’t it in GDScript?