Jam10/Scripts/Units/FollowReplay.gd

22 lines
540 B
GDScript3
Raw Normal View History

2023-01-30 08:56:47 +00:00
extends Unit
var replay : ReplayRecording = null
func process_unit(delta : float, time_elapsed : float):
self.time_elapsed = time_elapsed
if replay != null:
handle_replay(time_elapsed)
func handle_replay(at_time: float):
var frame: int = int(at_time / replay.time_per_frame)
var subframe: float = (at_time / replay.time_per_frame) - frame
pos = lerp(replay.position(frame), replay.position(frame + 1), subframe)
var sprite: int = replay.sprite(frame)
var index: int = sprite >> 3
sprite &= 7
set_sprite(sprite, index)