I need help with the respawning part of my movearound script. I want my character to respawn to a specific object in the game after he dies and in the world space cordinates. Here is the script:
the respawn part is in red.
var speed = 8.0;
var rotateSpeed = 3.0;
//Dying
static var dead = false;
//Getting hit
var tumbleSpeed = 800;
var decreaseTime = 0.9;
var decayTime = 1;
static var gotHit = false;
private var backup =[tumbleSpeed, decreaseTime, decayTime];
[COLOR="red"]function LateUpdate()
{
if(dead)
{
transform.position = Vector3(-200,8,-200);
gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10);
dead = false;
}[/COLOR] if(gotHit)
{
if(tumbleSpeed < 1)
{
//we're not hit anymore... reset get back in the game!
tumbleSpeed = backup[0];
decreaseTime = backup[1];
decayTime = backup[2];
gotHit = false;
}
else
{
//we're hit! Spin our character around
transform.Rotate(0, tumbleSpeed * Time.deltaTime, 0, Space.World);
tumbleSpeed = tumbleSpeed-decreaseTime;
decreaseTime += decayTime;
}
}
}
//function OnControllerColliderHit(hit : ControllerColliderHit)
function OnTriggerEnter( hit : Collider )
{
if(hit.gameObject.tag == "fallout")
{
dead = true;
//subtract life here
LifeControl.LIVES -= 1;
HealthControl.HITS = 18;
}
if(hit.gameObject.tag == "enemyProjectile")
{
gotHit = true;
//subtract health here
HealthControl.HITS -= 1;
Destroy(hit.gameObject);
}
if(hit.gameObject.tag == "pickUp")
{
Destroy(hit.gameObject);
}
}
function Update()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script RequireComponent(CharacterController)