A dungeon delver roguelike using Pathfinder 2nd edition rules
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added rotating character during movement

+12 -5
+12 -5
characters/character.gd
··· 4 4 @export var speed: float = 5.0 5 5 var target_position: Vector3 = Vector3.ZERO 6 6 var has_target: bool = false 7 + var target_rotation: float = 0.0 8 + @export var rotation_speed: float = 0.2 7 9 8 10 func _physics_process(delta: float) -> void: 9 11 if has_target: 10 12 var direction = (target_position - global_transform.origin) 11 13 direction.y = 0 12 14 13 - if direction.length() < 0.1: 14 - velocity = Vector3.ZERO 15 - has_target = false 15 + if is_equal_approx(global_rotation.y, target_rotation): 16 + if direction.length() < 0.3: 17 + velocity = Vector3.ZERO 18 + target_rotation = global_rotation.y 19 + has_target = false 20 + else: 21 + direction = direction.normalized() 22 + target_rotation = atan2(direction.x, direction.z) 23 + velocity = direction * speed 16 24 else: 17 - direction = direction.normalized() 18 - velocity = direction * speed 25 + global_rotate(Vector3.UP, (target_rotation - global_rotation.y) * rotation_speed) 19 26 20 27 move_and_slide()