2D TOWER TANK HOW TO TRACK ENEMY BY ANGLES INSTEAD OF LOTS OF COLLIDERS
I have all 8 animations idol and attacking depending on the directions of the enemy.
I am trying to do something like this, can anybody help with solving why I can't seem to get this to work
I have put this on the tank script
if (target)
{
var angleBetween = Quaternion.Angle(transform.rotation,
Quaternion.LookRotation(target.position - transform.position));
if(angleBetween > 0 && angleBetween <90)
SkelAnim.state.SetAnimation(0,FaceDown,true);
else if(angleBetween > 90 && angleBetween <180)
SkelAnim.state.SetAnimation(0,FaceLeft,true);
}
Answer by tormentoarmagedoom · Feb 05, 2019 at 04:42 PM
Good day.
You should debug your code to see the values of everything while running the game. So you can then see what is not true/false
One more thing, what happens if angle is exactly 90 or 180 ?... Use => or
Bye!
Your answer
Follow this Question
Related Questions
How to get the angle to animate the player when running? 0 Answers
Mecanim animation playing once on button press 2 Answers
How do I get my character to stop moving while he is attacking? 0 Answers
Death animation for enemy 0 Answers
AnimationComplete() Error 0 Answers