I’m new with Unity and need help.
In my game, when the enemy is present in a space on the terrain, it changes (such as wind direction, audio and static effects). I want this to occur regardless if the player is looking at the enemy or not.
I’m new with Unity and need help.
In my game, when the enemy is present in a space on the terrain, it changes (such as wind direction, audio and static effects). I want this to occur regardless if the player is looking at the enemy or not.
Look up how collider triggers work. Start with a box, turn isTrigger to true, create a script with something like so:
void Update()
{
if(collider.bounds.Contains(/*character position*/) == true)
{
//do stuff
}
}
Edit:
public class MagicBoxOfDoom: MonoBehaviour {
public GameObject enemy;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(collider.bounds.Contains(enemy.transform.position) == true)
{
Debug.Log(“HEY! I AM IN THE BOX”);
}
}
}