Implemented physics interpolation

This commit is contained in:
2024-02-27 21:05:55 +01:00
parent ca7fa120ea
commit 489a14061a
23 changed files with 226 additions and 68 deletions

View File

@ -1,16 +1,27 @@
class_name AnimationComponent
extends Node
extends CharacterComponent
@export var skip_frames: int = 0
var animations: AnimationPlayer
var state: StateComponent
var accumulated_delta: float
var skipped_frames: int
func _ready():
state = owner.get_node("State")
state = character.get_node("State")
state.transitioned.connect(on_transition)
animations = %AnimationPlayer
func _process(delta):
animations.advance(delta)
accumulated_delta += delta
if skipped_frames >= skip_frames:
animations.advance(accumulated_delta)
accumulated_delta = 0
skipped_frames = 0
else:
skipped_frames += 1
func on_transition(_from: StateComponent.State, to: StateComponent.State):
match to: