- Home /
Problem tags to animation
Hello everyone.
I do not understand the problem in this script.
the character when he shoots, the bullet by a TAG "HitEnemy" that triggers an animation, here everything works. But when the character with the TAG "Player" enters boxcollider2D, it also activates the animation. I do not understand the problem. The rigidbody is causing the problem?
Script:
using UnityEngine;
using System.Collections;
public class TriggerEnemy : MonoBehaviour
{
public Animator Animator;
void Start()
{
Animator = GetComponent<Animator>();
}
void Update ()
{
}
void OnTriggerEnter2D(Collider2D collider)
{
if(collider.gameObject.tag == "HitEnemy");
Animator.Play("subisce colpo");
}
}
Could you please clarify, what tag does the bullet have, the enemy have and the player have.
$$anonymous$$y current understanding is the player has tag "Player", the bullet has tag "HitEnemy" and the enemy tag is unknown. I think I'm reading the question wrong though.
the enemy must fulfill the animation when hit by bullet by, that works well. When I walk with the character (Tag "Player") within the boxcollider2D associated with the enemy, always makes the animation. I wish the character with the tag player will not activate the animation of the enemy. Only the bullet by should animate with the tag "HitEnemy". I hope I explained myself. ;-)
Your answer
Follow this Question
Related Questions
call/trigger animation of other object 2 Answers
Triggering a basic animation via Box Collider 4 Answers
Light animation and Main Menu animation at same time from 1 trigger 0 Answers
Multiple animation with One Trigger ?!! 1 Answer
Issues with Animator Controller - Trigger does not reset to false after being set with SetTrigger 2 Answers