Game freezes when enemies change state
Camp have you stopped using exports?
if these states are part of the statemachine, they would have to be children of the state machine and you can obtain them using a get_node()
/$
.
and we still don't have enough information because you posted what appears to be the BASE class of a number of other classes that do who knows what. there's still a billion unknown variables.
now, an idea: WHEN is change_state
executed? all you've shown us the ready
function, but claim that this problem happens WHEN changing state, meaning state is changed somewhere else.
meaning you are running this thing multiple times per frame on some other script and that could be the problem. my guess.
- Edited
xyz I tried cutting everything I could from the project but the file was too big because of the massive size of the assets. The artist I'm working with uses blender and makes spritesheets from 2d frames of the animations they make and they say they can't make them smaller. When removing things, I did find out that the freezing only happens when the scene starts off with a pickup for some reason, so it only happens when there's two or more different enemies and any number of pickups. I have no idea why. Here's the script for the pickup:
- Edited
xyz I was trying to do this and then found out that if I delete the AnimatedSprite2D of the pickup or delete the sprites of the enemies, the freezing goes away. Maybe the issue is from animation instead of enemies changing state, but that doesn't explain why it only happens when there's two different enemies and a pickup, unless the issue is that the file sizes are too big and the engine chugs trying to animate them, but I don't think I'm even at the scale where that's possible yet, especially with only two enemies.
If I delete the SpriteFrames resource from the pickup and keep the textures of both enemies, the game still freezes. If I delete the texture of one enemy and the SpriteFrames of the pickup or delete both enemies' textures and keep the SpriteFrames, it doesn't. I also tried deleting the player's texture and that also fixed the freezing.
- Edited
Camp It doesn't matter what does what. If you want to get it looked at and the project is too big, first try to delete the .godot, if still too big delete all scenes except the relevant one, if still too big resize all the images to 1/16th of their size, or smaller. The point is to reduce the size of the project for posting.