godot-4
Question
extends RigidBody3D
const Xe=deg_to_rad(90)
const Ye=deg_to_rad(0)
const Ze=deg_to_rad(0)
var kraad:Vector3
var vahe:Vector3
# Called when the node enters the scene tree for the first time.
func _ready():
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func _physics_process(delta):
print(rotation_degrees)
vahe.x = wrapf(Vector3(Xe, Ye, Ze).x - self.rotation.x, -PI, PI)
vahe.y = wrapf(Vector3(Xe, Ye, Ze).y - self.rotation.y, -PI, PI)
vahe.z = wrapf(Vector3(Xe, Ye, Ze).z - self.rotation.z, -PI, PI)
if(vahe.length()>0.01):
self.angular_velocity+=hookeslaw(vahe,self.angular_velocity,100,8)*delta
#move_and_slide()
func hookeslaw(displacmenet:Vector3,current_velocity:Vector3,stifness:float,damping:float)->Vector3:
return(displacmenet*stifness-current_velocity*damping)
func _on_body_entered(body):
print("miks") # Replace with function body.