- Home /
How do I make the terrain responsive to the enemy?
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.
Answer by PAEvenson · Nov 21, 2012 at 08:07 PM
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:
Create a box
Turn the mesh Collider OFF
Set the collider isTrigger to ON
Position the collider on the terrain
Add script to Enemy
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"); }
} }
Your answer
Follow this Question
Related Questions
Enemy walking through walls/terrain 1 Answer
Terrain Collision and Holes? 1 Answer
Make a simple tree 1 Answer
Non-NavMesh Enemy 0 Answers
AI Enemies? 1 Answer