eel moves on path

This commit is contained in:
pennyrigate 2023-06-13 03:25:17 -04:00
parent 56ee4ccb58
commit acaa6f2d52
3 changed files with 38 additions and 20 deletions

View file

@ -14,9 +14,10 @@ export var wave_amplitude: float = 4.0
onready var sector: Vector2 = Game.get_sector(global_position)
onready var hitbox: Area2D = $Hitbox
onready var hitbox: Area2D = $Path2D/PathFollow2D/Hitbox
onready var first_segment: CollisionShape2D = $"%Segment"
onready var segment_start: Position2D = $"%SegmentStart"
onready var path_follow = $Path2D/PathFollow2D
func _ready() -> void:
@ -25,12 +26,13 @@ func _ready() -> void:
var new_segment = first_segment.duplicate()
new_segment.position.x = segment_start.position.x + SEGMENT_LENGTH * float(i)
hitbox.add_child(new_segment)
$Hitbox/TailShape.position.x = segment_start.position.x + SEGMENT_LENGTH * segments
$Path2D/PathFollow2D/Hitbox/TailShape.position.x = segment_start.position.x + SEGMENT_LENGTH * segments
_wave_segments()
func _physics_process(delta: float) -> void:
# move
global_position.x += speed * delta * sign(scale.x)
# global_position.x += speed * delta * sign(scale.x)
path_follow.set_offset(path_follow.get_offset() + speed * delta)
# make segments wibble
_wave_segments()
# check for wrapping