I have some code that activates attack collision when certain sprites are played during the attack animation. The code works with the player character (attack hitboxes appear), but not with enemies (attack hitboxes don’t appear at all) . There are no error messages in the console. Here is the code:
Are you sure you have all public variables assigned correctly? maybe you are swaping enemiy/player objects in the variable assign (in inspector). But, as i normally say in this cases…
For this kind of problems, you need to learn to find your problem by your own. As you can imagine, we can not try to read all scripts people posts, understand the logic and process, what all variables means, when or how you use them, and find where is the “problem”. You are the only one who can do it…
You need to debug the code while running, and check the states of all variables at the moment you see the problem, and I’m sure you will detect what is not how it was suposed to be.
If don’t know how, look for some tutorials on how to debug code while running.
There is no reason for not working, it is simple line of code. So you have some issue out of this line. Let’s see…
1) Check if you drag&drop all GameObjects.
2) Check if you call this method. Just add Debug.Log(“I am calling, i am fine”); under attack1Box.gameObject.SetActive (true); . And see in the inspector if there is “I am calling, i am fine”.
3) Check if somewhere else you are deactivating this game objects, from other script maybe.
@tormentoarmagedoom @bakir-omarov
Thank you, I’ve found the problem - my state mashine for some reason doesn’t see the “Attack” state. Attack animation plays, but without the state, it’s just that - an animation. Now I just need to find a way to activate the state.