Implemented physics interpolation
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user