I have a enemy who already is scripted to follow me but once he gets really close he just goes around in circles. I’m wondering if the enemy could kill the player somehow and then it goes red and say try again or something similar to that.
All I need is a script so when the enemy gets atleast a metre away from the player says that you’ve died and says try again so then when you click it, it’ll restart the game. Please help ASAP!
Have you seen the scripting reference? It’s your friend!
You want OnTriggerEnter or OnCollisionEnter (the first one is called when an object enters a ‘trigger volume,’ and the second is called when two objects bump into each other) to detect the enemy hitting your player. (I’d recommend a Trigger, since you’re concerned with distance rather than actual contact).
Text can be done with either a GUI.Label in the OnGUI function, or with Unity’s simple 3D Text object from the Object menu.
Once your enemy hits the trigger, set a boolean to true. While that boolean is true, display the ‘try again’ screen (either enable the text object, or have the OnGUI function switch to displaying the label). You can use a GUI.Button to listen for the player clicking something, or just listen to Input for a mouse button.