- Home /
Question by
Tornado Gaming · Dec 01, 2013 at 09:50 PM ·
horrorendgame
How do I make my game end when something comes near the player?
I am making a game like Slender. The enemy comes towards the player like it should do, but the player does not die. I want to make it so that when the enemy comes into a certain radius of the player, another scene is loaded (which will have a cut scene). This is my script:
var target : Transform;
var moveSpeed = 3;
var rotationSpeed = 3;
var myTransform : Transform;
function Awake(){
myTransform = transform;
}
function Start () {
target = GameObject.FindWithTag("Player").transform;
}
function Update () {
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
myTransform.position += myTransform.forward*moveSpeed*Time.deltaTime;
}
Comment
Your answer
Follow this Question
Related Questions
Help with a killbox 1 Answer
Need an enemy script that makes him wander and detect 1 Answer
disable GUI when loading is done 5 Answers
Audio Destroy Help! 1 Answer
Instantiating glass shards(gibs) when light explodes. 1 Answer