- Home /
kill boundary script
does anyone know a script that when you walk into the area it will kill your character? if so what is the script? also how would i insert the script into the game so that the block is invisible?
I would also like a script that gives you time to return to the game area.
Answer by aldonaletto · Jul 11, 2011 at 01:07 AM
You can use triggers to check when something enters that area. A trigger is just a collider in which you set the Is Trigger option. You can create a cube, adjust its position and size (scale) to the area you want to cover, and check the Is Trigger option. Name it "KillArea", then disable the Mesh Renderer : the trigger will become invisible.
Include the OnTriggerEnter function in the player script:
function OnTriggerEnter(col:Collider){
if (col.name == "KillArea"){ // die only in this trigger!
// do whatever you want to kill your player:
// zero health, decrement lives, make him scream, etc.
// or just write a message to the console to test this trigger:
print("Arghhh... I'm dead!");
}
Well, the rest is on you. A good start point is to download the FPS Tutorial Completed and follow the instructions found in FPS_Tutorial_1 to 3.
Your answer
Follow this Question
Related Questions
My player HP are get decreased from several GameObjects that has is Trigger on 0 Answers
Lower Object Health If Collides With "Player" Tag,Lower Object Health If Collides With Player Tag 1 Answer
OnTriggerEnter Being Called On Unexpected Object 1 Answer
I'd like some help with my health / shooting (collision detection) 1 Answer
Collission and Trigger on Same object 0 Answers