- Home /
trigger problem
code problem in a 2d game: when the character touches an object the animation of the object activates (using trigger) and dissapears, the problem is that this object has to reset and reappear again after that in front of the character, for that I created another trigger with a new condition and call it in the code, but is not working. I want to create a loop of this object animation, so everytime the character touches and object, the object has to dissapear and then reappears again after the character pasess a specific position. Here is the code of the part where I call the triggerr of the object:
using UnityEngine; using System.Collections; public class objectScript : MonoBehaviour { private Animator anima; void Start () { anima = this.gameObject.GetComponent(); } void OnCollisionEnter2D (Collision2D Colision) { if (Colision.gameObject.name == "Character") { anima.SetTrigger("objectdissapear"); } if (Colision.gameObject.name == "object2") { anima.SetTrigger("objectreappear"); } } }
Please format the code so we can read it and try to help. Also I think we're going to need to see more code than this.