1 Idle animation doesn't play
If the animation is getting stuck on the first frame, my hunch is that stateMachine.travel("Idle");
is being called repeatedly and that is resetting the animation, or another animation is being called before it and then the animation is changed to idle right after, leading it to be reset.
I would add a condition that checks if the animation is already set to idle
and only play idle
if the animation is different. If that does not work, then I'd try printing the name of the animation state right before calling idle
and see if it's being set to something else.
2 How would I add other idle animations
If it was me, I'd count how many times the idle
animation has looped and then after a certain number, play one of the special idle animations instead. However, looking quickly through the code for AnimationTree's, it looks like there isn't a good way to tell if an animation just finished.
In this case, I'd use a timer instead. Something like this (pseudo code):
var time_spent_in_idle = 0
const IDLE_CHANGE_ANIM_TIME = 2
var special_idle_anim_names = ["IdleStand_Alt01", "IdleStand_Alt02"]
func _process(delta):
# other code
if (state_machine.get_current_node == "IdleStand"):
time_spent_in_idle += delta
if (time_spent_in_idle >= IDLE_CHANGE_ANIM_TIME):
var random_idle_index = round(rand_range(0, special_idle_anim_names.size()-1))
state_machine.travel(special_idle_anim_names[random_idle_index])
else:
time_spent_in_idle = 0
Not sure on this one, to be honest. It might be the transitions that are causing the issue. You could try calling state_machine.stop()
right before changing states to see if that helps, but I'm not sure why it would be being called.
Another thing that potentially, maybe, could be causing the issue is the use of is_on_floor
, as it may be that the time between the jump and _physics_process
is where the animation is changing. You could try adding a grounded boolean in _physics_process
, setting it to is_on_floor
right after calling move_and_slide
, and use that instead of is_on_floor
and that might help?
4 Player starts the scene in their jump animation
Maybe a transition to the jump animation is forcing it to play? I don't see anywhere in code that would trigger it automatically.
5 'JumpPeak' plays a little late
You could try transitioning to JumpPeak
right when the velocity goes from low to high (I.E the player is no longer ascending) but I have no idea how hard that would be to implement.
Before trying any of the suggestions, I would highly recommend making a backup of the project!
All of that said: I haven't used the built-in animation state machine myself, so I'm mostly just making guesses based on my knowledge in other Godot areas, but it probably means I'm wrong on several points and I wouldn't want you to lose anything.