Hey everyone! I’m having a small problem with my collisions. You see when I enter the collision area it works fine and the collision becomes true but when I leave it it doesn’t go back false. Any of you got any ideas why? Here’s the code!
using UnityEngine;
using System.Collections;
public class RunAfter : MonoBehaviour
{
public Transform targ;
public Transform body;
public bool player;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
player = true;
}
}
void OnTiggerExit(Collider other)
{
if (other.tag == "Player")
{
player = false;
}
}
void Update()
{
if (player == true)
{
body.transform.Translate(Vector3.right*0.15f);
}
transform.position = new Vector3(body.position.x, body.position.y, body.position.z);
}
}