- Home /
Beginner - End game by touching certain object
HI
I am totally new to Unity 3D and I have absolutely no coding knowledge. Basically all I want to do is to end the game when my player (standard Unity First Person controller) touches a FBX model of a house. Maybe by switching to another scene that would show an end game message?
Is there a simple way to do this? I guess a script is involved? I have a brief understanding of how scripts are attached and used but I have no idea how to go about actually creating my own. So far my google searches haven't amounted to any concrete answers.
Answer by Graham-Dunnett · Jan 28, 2015 at 10:28 PM
Read up on Collisions.
Thanks Graham! Figured it out
Used a java script and attached it to my "End Game" object:
function OnTriggerEnter () { Application.LoadLevel ("enter scene name here"); }
Added my game scene and "end game" scene to the build settings (file-> build settings).
Then added the above script to the End Game object (enter the end game scene where it reads "enter scene name here").
Also remember to add a rigidbody (mark as "is kinematic") to the end game object and to mark the object's collider "is trigger" function.
If your player then touches the end game object you will be taken to the end game scene