Improved component system
This commit is contained in:
@ -9,17 +9,13 @@ var angle: float
|
||||
|
||||
func _ready():
|
||||
assert(root, "Rotation root needs to be set")
|
||||
|
||||
if owner.has_signal("direction_changed"):
|
||||
owner.direction_changed.connect(on_direction_changed)
|
||||
|
||||
update_configuration_warnings()
|
||||
owner.controller.direction_changed.connect(on_direction_changed)
|
||||
|
||||
func _process(delta):
|
||||
if direction != Vector3.ZERO:
|
||||
angle = atan2(direction.x, direction.z)
|
||||
|
||||
root.rotation.y = lerp_angle(root.rotation.y, angle, rotation_speed * delta)
|
||||
|
||||
func on_direction_changed(new_direction: Vector3):
|
||||
direction = new_direction
|
||||
direction = new_direction
|
||||
|
||||
if direction != Vector3.ZERO:
|
||||
angle = atan2(direction.x, direction.z)
|
Reference in New Issue
Block a user