- Home /
Animation Event not working properly
Hello, I'm trying to implement shooting animations, i use this code, but somehow i cant shoot anymore after some time, because "AnimationEnded" stays true. I think this would happen if it would be set to true while the animation is still running, but the Event is at the end of the animation... I have no clue whats happening.
Event Class: public bool animationEnded = true;
public void animationEndedController()
{
animationEnded = true;
animator.SetInteger("AnimationState", 0);
}
Player Code(Runs in Update):
if (Input.GetMouseButtonDown(0) && gun.animationEnded)
{
gun.animationEnded = false;
weaponAnimator.SetInteger("AnimationState", 1);
RaycastHit hit;
if(Physics.Raycast(cam.transform.position,cam.transform.forward,out hit))
{
int dmg = 10;
if (hit.transform.tag.Equals("Head"))
{
dmg = 20;
}
if (hit.transform.root.tag.Equals("OtherPlayer"))
{
client.playerDamageToServer(hit.transform.root.gameObject.GetComponent<Player>().id, dmg);
}
}
}
shootingtoidle.png
(30.6 kB)
shooting.png
(61.6 kB)
Comment