Godot Version
4.3
Question
I’m making a VR game and I need the sword (rigidbody) to be locked on the local axis when piercing something.
In short,
axis_lock_linear_y = true
would be exactly what I need if it didn’t only work for the global axis.
Test it yourself:
-
- Create a rigidbody3D in main scene.
-
- Set gravity to 0
-
- Rotate 45º
-
- try it yourself
extends RigidBody3D
func _integrate_forces(state: PhysicsDirectBodyState3D) -> void:
var input = Input.get_vector("move_left","move_right","move_forward","move_backward")
var dir = transform.basis * Vector3(input.x,0,input.y)
apply_central_force(dir)
--axis_lock_linear_z = true--
-
- Now try to lock it on the local z or x axis
ok, how should this be done?