Hello. I'm making an horror game, and i want that when the player enter inside a trigger an object (The enemy, away from the player by X distance) become visible but when the player isn't inside the trigger the enemy is not visible. And then, after the enemy has appeared, it destroys and never appear again.
I'm using this code (i made it, i'm not a good programmer) just for doing the first part (i've no idea how to do the other) but i don´t know if attach it to the trigger or to the enemy :
var Enemy : GameObject;
function Start () {
GetComponent(MeshRenderer).enabled = false;
}
function OnTriggerEnter (other : Collider) {
if(other.gameObject.tag == "Player"){
GetComponent(MeshRenderer).enabled = true;
yield WaitForSeconds(3);
GetComponent(MeshRenderer).enabled = false;
}
}
So, after that all, i'd like that when the player gets more notes, the enemy appear nearer and nearer. I hope you can help.
↧