Hey guys, Just creating a 3rd person game, and wanted our character to respawn to a check point when he collides with game objects. Any ideas? Thanks Sophie x
Hi Sophie,
I'd suggest you go through the 3rd person platformer tutorial before creating your 3rd person game. They do exactly what you require, i.e respawning at a certain point, and I'm sure the tutorial will teach you most of what you need to know to jump start your game.
The tutorial can be found at... http://unity3d.com/support/resources/tutorials/3d-platform-game
Good luck!
I would suggest watching a video from tornadotwins on youtube.com/ In some part it says how to make your character re spawn
Here is the code i use, you create a empty game object. Drag the script to your FPS controller, drag the empty game object to the reaspawn slot in the inspector and that should work!
var SpawnPoint : GameObject;
function Awake()
{
SpawnPoint.transform.position = transform.position;
}
function Update() {
if(transform.position.y < -20) {
forceRespawn();
}
}
function forceRespawn()
{
transform.position = SpawnPoint.transform.position;
}
function OnControllerColliderHit(hit: ControllerColliderHit) {
if (hit.gameObject.name == "Respawn") {
forceRespawn();
}
}