- Home /
Script to make an enemy follow the player when they trigger a door?
Hello!
I'm currently working on a new game with a group called Exclavian Studios.
Our current project is to make a Horror Puzzle Game called "Memorize."
Right now, I'm running into a bit of an issue.
In the Scene, there is 8 doors. 7 of which have a "Monster" that is supposed to chase you once you open the door. Currently, the script I'm using is just making them chase you straight off of the bat and they are glitching through the walls and it's wierd as heck.
If this helps, here is the script that is opening the doors:
var AngleX:float = 0.0;
var AngleY:float = 0.0;
var AngleZ:float = 0.0;
private var targetValue : float = 0.0;
private var currentValue : float = 0.0;
private var easing : float = 0.05;
var Target : GameObject;
function Update(){
currentValue = currentValue + (targetValue - currentValue) * easing;
Target.transform.rotation = Quaternion.identity;
Target.transform.Rotate(0,currentValue,0);
}
function OnTriggerEnter (other :Collider){
targetValue = AngleY;
currentValue = 0;
}
function OnTriggerExit (other :Collider) {
currentValue = AngleY;
targetValue = 0.0;
}
What that does, is when the play enters the Trigger zone on a door, the door will open. Simple stuff.
What I WANT to happen, is when the player enters that Trigger, and if there is a monster in that area, I would like the Monster to chase them and when they reach the player within say 5 X/Y, the game will enter into the "Kill" Scene.
Now, if they enter the empty room, then the game will enter the "To be continued" scene since this game is only in Alpha.
If anyone can help me out or has any questions, please let me know and I'll get back to you!
Thank you.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
How do i make zombies? 2 Answers
Enemy AI Help? 1 Answer
Enemy Targetting Help 1 Answer
How can I get this script to work? 1 Answer