godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.59k stars 21.1k forks source link

Animation wont play during runtime. #98581

Open hipturre opened 3 hours ago

hipturre commented 3 hours ago

Tested versions

System information

Godot v4.3.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4070 (NVIDIA; 32.0.15.6094) - 13th Gen Intel(R) Core(TM) i7-13700KF (24 Threads)

Issue description

For the last week I've been pulling my hair out on why this one state machine is broken. I've deleted it, remade it, renamed it, done everything I can and for some reason it will not play some animations. There is a player scene with an animation tree in it with a state machine. This state machine has two more state machines inside it, one is the moving state machine and the other is the attacking state machine. These systems have been removed from the MRP and are just traveled to and from using some basic code. Inside the attacking machine is where the problem lies. The attacking machine is supposed to play an attack animation, and then at the end, a returning animation in which the player can move to get out of it. Unfortunately, the two states in there play just one animation, if I switch it to anything but the "Baked_Player_Blunt_Wep_Small_Attack_1" animation, it will not play ( technically it does but it stays at frame 0, according to the playback). However, this only occurs after switching the animation of those states by code. Setting them in the editor prompts them to work just fine, as long as they aren't tampered by the code. BUT, this only applies to any other animation than the one I listed earlier, "Baked_Player_Blunt_Wep_Small_Attack_1". Setting both states to that animation via code works perfectly fine. This has been frustrating, to say the least.

Steps to reproduce

In the MRP below, I've ripped out about 95% of the project and this still persists, yet for some reason, I can't get this situation to occur when creating a project from scratch.

Minimal reproduction project (MRP)

MRP.zip

bikemurt commented 2 hours ago

I don't think this is an engine bug. I stripped out the wait calls, and all the hitbox logic (they were throwing errors), and the animation tree moves to the "attacking_machine" with no problem via code. The "Baked_Player_Blunt_Wep_Small_Attack_1_Return" does not play because you transition away from "return_node" to "End" immediately inside that state machine - in other words, I don't think your conditions are set up properly.

https://github.com/user-attachments/assets/e14fcbc2-a60f-478a-aa42-c5566bbe1bc4

I've uploaded another MRP with those things stripped out that you can try out. MRP.zip

If you really want to wait 3 seconds prior to switching to the attack animation, add this to the top of player.gd inside _ready():

await get_tree().create_timer(3.0).timeout