Compare commits

..

No commits in common. "fe8bebd875a3664b1cf914ae11a896173d9e8bcd" and "a44accebe463b7594d38cae1893322e3eb385808" have entirely different histories.

3 changed files with 10 additions and 17 deletions

View file

@ -20,6 +20,7 @@ layer_0/tile_data = PackedInt32Array(1114138, 262144, 1, 1048602, 0, 1, 983066,
position = Vector2(203, 60) position = Vector2(203, 60)
collision_layer = 2 collision_layer = 2
script = ExtResource("2_pk6k4") script = ExtResource("2_pk6k4")
speed = 100
[node name="Sprite2D" type="Sprite2D" parent="Player"] [node name="Sprite2D" type="Sprite2D" parent="Player"]
texture = ExtResource("2_0flm2") texture = ExtResource("2_0flm2")

View file

@ -90,9 +90,9 @@ func look_at_player(delta : float) -> float:
self.rotation_degrees += clampf(average_angle, -2 * PI * delta * turn_speed, 2 * PI * delta * turn_speed) self.rotation_degrees += clampf(average_angle, -2 * PI * delta * turn_speed, 2 * PI * delta * turn_speed)
return average_angle return average_angle
func follow_player(angle : float, delta : float): func follow_player(angle : float):
if(target_distance > follow_keep_distance): if(target_distance > follow_keep_distance):
self.apply_central_force(Vector2.RIGHT.rotated(self.rotation).rotated(deg_to_rad(angle)) * speed * delta * 60) self.apply_central_force(Vector2.RIGHT.rotated(self.rotation).rotated(deg_to_rad(angle)) * speed)
pass pass
@ -100,7 +100,7 @@ func _physics_process(delta: float):
var angle := look_at_player(delta) var angle := look_at_player(delta)
match state: match state:
STATES.TARGETING: STATES.TARGETING:
follow_player(angle, delta) follow_player(angle)
STATES.IDLE: STATES.IDLE:
# Do Idle Stuff # Do Idle Stuff
print("Dam, Nice a pause, time for a Coffee") print("Dam, Nice a pause, time for a Coffee")

View file

@ -1,24 +1,16 @@
extends CharacterBody2D extends CharacterBody2D
@export var speed = 100 @export var speed = 50
@export_range(0, 1) var damping_factor := 0.6
func get_move_vector(): func get_move_vector():
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized() var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
return input_direction return input_direction
func move_player(delta : float):
if get_move_vector() == Vector2.ZERO:
# Damp Players Velocity if no Input
self.velocity = self.velocity * (1 - min(1, damping_factor * 60 * delta))
else:
# Set Players Velocity to the Input Direction in the Players Speed
self.velocity = get_move_vector() * speed * delta * 60
# Update The Players Physics Calculations func _physics_process(delta):
# Set Velcoity to Move Vector times speed
self.velocity = get_move_vector() * speed
# Do the Physics-Calculations of the Player
self.move_and_slide() self.move_and_slide()
pass pass
func _physics_process(delta : float):
move_player(delta)
pass