- Home /
Check for collision while animating
I have an animation 0.24 sec long (Hammer Hitting). All I want to do is check if the hammer collider collided while playing animation and do something, and do something else if the animation finished without colliding sounds simple but I dont know why its not working currently I am starting a function (Lets call it function A) that runs yield WaitForSeconds(0.24);
at the same time I call anim.SetTrigger("HammerHit");
(When the mouse is clicked) and on OnCollisionEnter I have a bool called col
that turns true
if collided and that's how I know a collision happend , after yield WaitForSeconds(0.24);
if col = false
that means no collision happens that's basically what I have. Whats currently happens is it most of the time works,Great. But some times it dose what is on function A after yield WaitForSeconds(0.24);
(which suppose to happen only if there is no collision) and at the same time it dose whats on OnCollisionEnter (which suppose to happen only if there is a collision) am sure am doing it long or in a wrong way but basically what I want is Do something if collided while animating and do something else (after animation is done) if there is NO collision while animation
Your answer
Follow this Question
Related Questions
Change scene with trigger collision not working. 1 Answer
Why the npc character walking strange when using a Rigidbody and Is Kinematic on enabled ? 1 Answer
Is it possible to check how much a trigger is filled by %? 1 Answer
Is it possible to detect different colliders with one script ? 1 Answer
Prevent instantiating on collider 1 Answer