I have a game where you roll a ball around and collect a bunch of yellow cubes. I have a restart button already, so the player can click it when they mess up or want to restart, but I want there to be an auto-restart/teleport/portal so that if the player falls to the lower ground, they get sent back to the starting position, and their score resets. Here is a small picture.
All answers are appreciated! Thanks in advance!
Try putting a cube where when the player touch the cube, the game will restart.
Remove the “Mesh renderer” (or not, but the cube will be able to see) and, in the BoxCollider check the parameter “is trigger”
Now, make a script (JavaScript or UnityScript) with the following:
#pragma strict
function OnTriggerEnter (other: Collider){
//Here is where you need to put your restart code, the same code as the button
}
Attach the script to the cube and try it.
Tell me if it worked.
Greets
Well or you can have a simple statement like this
float someValue;
void Update()
{
if(player.transform.position.y <someValue)
RestartGame();
}
set the someValue to a point below your plane and it should work. That way you don’t have to place triggers all around the plane but it have some restrictions on the way you design the level.
(if you attach that code to the player change the statement to gameObject.transform.position.y)