ft: wrapping manager overhaul
This commit is contained in:
24
evolve-die-repeat/molecular/prey/collision.gd
Normal file
24
evolve-die-repeat/molecular/prey/collision.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
var desired_rotation: float = self.rotation
|
||||
@export var speed = 0.5
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
# smoothly rotate
|
||||
if self.rotation != self.desired_rotation:
|
||||
self.rotation = lerp_angle(self.rotation, self.desired_rotation, clampf(4 * delta, 0, 1))
|
||||
|
||||
func move(motion: Vector3, mod: float) -> void:
|
||||
move_and_collide(Vector2(motion.x, motion.y).normalized() * self.speed * mod) # Moves along the given vector
|
||||
self.desired_rotation = atan2(motion.y, motion.x)
|
||||
|
||||
# Apply boundary to new position
|
||||
position = GameManager.get_boundaried_position(position)
|
||||
|
||||
|
||||
func duplicate_init() -> void:
|
||||
var sight = $Sight
|
||||
remove_child(sight)
|
||||
sight.queue_free()
|
||||
Reference in New Issue
Block a user