first init
This commit is contained in:
31
Assets/thruster_cube.gd
Normal file
31
Assets/thruster_cube.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends RigidBody3D
|
||||
|
||||
var torque_force: float = 10000.0
|
||||
|
||||
func _physics_process(delta):
|
||||
var local_torque := Vector3.ZERO
|
||||
|
||||
# Pitch
|
||||
if Input.is_action_pressed("w"):
|
||||
local_torque.x -= 1
|
||||
if Input.is_action_pressed("s"):
|
||||
local_torque.x += 1
|
||||
|
||||
# Yaw
|
||||
if Input.is_action_pressed("a"):
|
||||
local_torque.y -= 1
|
||||
if Input.is_action_pressed("d"):
|
||||
local_torque.y += 1
|
||||
|
||||
# Roll
|
||||
if Input.is_action_pressed("q"):
|
||||
local_torque.z += 1
|
||||
if Input.is_action_pressed("e"):
|
||||
local_torque.z -= 1
|
||||
|
||||
# Apply local torque converted to world space
|
||||
if local_torque != Vector3.ZERO:
|
||||
var world_torque = global_transform.basis * local_torque.normalized() * torque_force * delta
|
||||
apply_torque(world_torque)
|
||||
|
||||
print(angular_velocity)
|
||||
Reference in New Issue
Block a user