Hello - when my third person controller walks into a collider, he is destroyed, and a new third person controller is set to active in the exact same position, but rotated 180 degrees.
This script works - but I would like the character to be set in the same position as the first third person controller, but -3 on the x axis.
I just can’t work out how to script this correctly - I tried this line:
carl.transform.position(new Vector3(characterPosition-3, characterPosition, characterPosition));
But this came up with a lot of errors. How do I transform a character to this character position, but -3 on the x axis?
This is my SetCharacterToActive script (JavaScript):
var carl : GameObject;
var vincentCamera : GameObject;
var thirdPerson : GameObject;
var script : SwitchCharacters;
var playerGO : GameObject; //Should be filled with the GameObject the SwitchCharacters script is attached to
private var hasPlayed = false;
var characterPosition : Vector3;
function Start () {
carl.SetActive (false);
vincentCamera.SetActive (false);
}
function OnTriggerEnter () {
if (!hasPlayed&&!thirdPerson.active){
characterPosition = GetComponent(DestroyCharacterVincent).firstCharacterPosition;
carl.transform.position = characterPosition;
carl.transform.Rotate(new Vector3(0, 180, 0));
carl.SetActive (true);
vincentCamera.SetActive (true);
script.cam02 = carl.Find("VincentCamera");
script = playerGO.GetComponent(SwitchCharacters);
script.player02 = carl;
hasPlayed = true;
}
}
Thanks so much, Laurien