Compare commits
No commits in common. "fe8bebd875a3664b1cf914ae11a896173d9e8bcd" and "a44accebe463b7594d38cae1893322e3eb385808" have entirely different histories.
fe8bebd875
...
a44accebe4
3 changed files with 10 additions and 17 deletions
|
@ -20,6 +20,7 @@ layer_0/tile_data = PackedInt32Array(1114138, 262144, 1, 1048602, 0, 1, 983066,
|
|||
position = Vector2(203, 60)
|
||||
collision_layer = 2
|
||||
script = ExtResource("2_pk6k4")
|
||||
speed = 100
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="Player"]
|
||||
texture = ExtResource("2_0flm2")
|
||||
|
|
|
@ -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)
|
||||
return average_angle
|
||||
|
||||
func follow_player(angle : float, delta : float):
|
||||
func follow_player(angle : float):
|
||||
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
|
||||
|
||||
|
||||
|
@ -100,7 +100,7 @@ func _physics_process(delta: float):
|
|||
var angle := look_at_player(delta)
|
||||
match state:
|
||||
STATES.TARGETING:
|
||||
follow_player(angle, delta)
|
||||
follow_player(angle)
|
||||
STATES.IDLE:
|
||||
# Do Idle Stuff
|
||||
print("Dam, Nice a pause, time for a Coffee")
|
||||
|
|
|
@ -1,24 +1,16 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
@export var speed = 100
|
||||
@export_range(0, 1) var damping_factor := 0.6
|
||||
@export var speed = 50
|
||||
|
||||
func get_move_vector():
|
||||
var input_direction = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized()
|
||||
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()
|
||||
pass
|
||||
|
||||
func _physics_process(delta : float):
|
||||
move_player(delta)
|
||||
pass
|
||||
|
|
Reference in a new issue