Conditions ignored because of file locations

Godot Version

4.2.1 stable

Question

First of all I’m using states to manage the player like idle, move, fall, jump, etc. The amount of possible jumps is capped by counting the jumps and capping that number. So the issue I am facing is that those conditions are ignored while in the attack state meaning the player can jump infinitely into the air as long as they press jump and attack at the same time. I believe this is because the attack function utilizes a script which is attached to another node under the main player node and since that script is initialized on attack then it ignores the conditions because it is not aware of them from where it sits in the file directory. What can I do, the attack script that is in a different place than the other scripts is there because it controls the “arm” of the player which has the area2d on it that allows for interaction between it and other bodies such as enemies such as adding a force to the enemies when attack is initialized and the area2d and enemy are colliding.

Can you provide a screenshot of your node setup
and the script that controls the behaviour / contains the conditions?


In the script attached to the player node there is a condition that says can_jump is false if jump_count is greater than or equal to max_jumps and jumps are added and subtracted to the counter in their respective scripts depending on which state etc. The script which i believe is causing the issue is under the arm node, which is used when the attack state is called.

Is there a specific reason why you have all these states as separate nodes (and even scenes) ?

I understand using composition as your pattern, but this seems a bit much, especially if it causes issues?

That being said, it sounds like you need to investigate/add the condition check that happens before your attack is called.
If you check is the jump cap is reached before you call the attack, it should probably help narrow down any issues, but that’s hard to say without seeing the code.

I’d also recommend addinng some debug messages so you can more easily trace back what happens.

1 Like

Lol I’m using this state machine I saw a video on from PracticalNPC. I tried adding checks everywhere and it seems like my can jump and jump count variables are being set correctly just that they are ignored in attack. I even moved the arm node to be child of the attack node then I tried the states node and it still persists. I’m still looking into it but I’m sure I’ll find the solution still very new to coding lol