So I have a code for an enemy that uses state machines. It is a coyote that is supposed to follow a sheep.
When it enters the "seeking" state it gets the body.global_position of the sheep (through the variable "sheep") and follows that direction until the sheep has been bitten (entering the "bite" state) or it goes out of sight (goes back to "wander" state)
Up to that point it works. but when the coyote actually enters the "bite" state (meaning it has come in contact with the sheep) the "sheep" variable becomes null and the "seeking" states breaks. I don't understand why this happens.
(adding image of the main code that triggers the states)
Let me know if you need more info