4.4
how to code Idle animation to play Idle 2 and 3 depending on how much time player’s Idle?
4.4
how to code Idle animation to play Idle 2 and 3 depending on how much time player’s Idle?
Accumulate player’s idle time and when it crosses a certain threshold - switch to next animation.
Ok how?
func _idle_state():
print("Idle")
animated_sprite.play("Idle")
$Ground.disabled = false
$AirHover.disabled = true
$AirForward.disabled = true
if Input.is_action_just_pressed("Fly"):
velocity.y = JUMP_VELOCITY
current_state = States.FLYING
if Input.is_action_just_pressed("Interact"):
for area in $InteractZone.get_overlapping_areas():
if area.has_method("on_interact"):
area.on_interact(self)
current_state = States.INTERACTING
elif Input.is_action_pressed("EnterCall"):
current_state = States.TALKING
Who and when calls _idle_state()?
If the animations are always played in the same sequence, then you can combine them into a single idle animation.
When Player speed is 0 and is on Ground
issue with that i will have to extend Normal Idle animation Frames alot
That’s when. Now who does it?
A simple generalized solution would be to just tween the sequence of animations. As soon as player touches controls - cancel the tween.
func _ready(): Call Idle State when game Start
func _ready():
states[States.IDLE].call()
You can do it with a tween as I mentioned above.
that works with animatedSprite2d?
It works with anything. Sequence the play() calls using tween_callback() and tween_interval()
Thanks, i will go to documents to learn about tween and how it works
They have to go somewhere. Whether they’re spread over many small animations or a single large animation is usually just a personal preference. They are the same either way, unless you need to reuse the animations elsewhere.
ye this could work too