Help with OnTriggerEnter Not working correctly?
I would like some helping on figuring out why this OnTriggerEnter doesn't modify the booleans gotHit and canMove. This code is supposed to allow my player to be hit by the enemy and play a staggering animation while not allowing my player to move and reduce it's health, but only the health part works.
void OnTriggerEnter(Collider hit)
{
if (hit.gameObject.name == "L Hand Box")
{
gotHit = true;
health.CurrentVal -= 20;
if (this.anim.GetCurrentAnimatorStateInfo(0).IsName("standing_react_large_gut"))
{
canMove = false;
}
else
{
canMove = true;
}
}
else
{
gotHit = false;
}
}
Answer by PhantomSarcasm · May 19, 2016 at 01:40 PM
the first thing I do is use "print" or "debug.log" to see if it comes in if collision. proves that this coming into your first "if", I'm not sure but quisas, one of the two objects colicionar not have the active trigger or not have the regidibody ..... it sounds like an insult but small things habeses they are the first to be forgotten, remember that it objects to colicionar one must have "rigidibody" and some other either has to have the active is_triger. as I said before do not take it as an insult but first rule out the simplest things besides ..... I'm not sure this cojiendo object name spaces, usually not put spaces in the name to avoid any problems ..
I have tested a debug.log to see if the collisions work and i can confirm that they do work and output the message. Like I said the "health.CurrentVal -= 20;" but the rest just doesn't work properly or at all.
I do not have a clear answer you I am noobster and do not have much knowledge of what it is "GetCurrentAnimatorStateInfo" forgive not be of help
That's ok, Thanks for trying to help anyways. I use "GetCurrentAnimatorStateInfo" to check if the animations is currently playing, and if it is, i make it so that the player can't move.
Your answer
Follow this Question
Related Questions
How in move make Y=1 everytime ? 1 Answer
Doodle Jump Game Platform Spawn Issue Unity2D 0 Answers
ANIMATION STRANGELY DOES NOT PLAY 0 Answers
Animation triggered by other animation, script, c# 1 Answer
I spent 6 hours and I failed to launch a ball forward? I could not figure out what is happening? 1 Answer