Hi - in this script I have an object which moves towards the first person controller when that is active, and third person controller when this one is active.
Halfway through the game, the third person controller will be destroyed and a new one instantiated in its position - but I would like the object to then move towards this new third person controller.
I can’t give them both the same tag, so I’m not sure how to phrase the script - so that when the first person controller isn’t active and the original third person controller isn’t active it follows the new one?
Sorry - I haven’t got a script example of the ones I’ve tried as I haven’t got any that just don’t throw lots of errors.
If anyone could give me a pointer of where to look online or how to do it that would be amazing!
Thanks, Laurien
#pragma strict
var targetF : Transform;
var targetT : Transform;
var firstPerson : GameObject;
function Update () {
if (firstPerson.GetComponent(CharacterController).active) {
transform.position = Vector3.MoveTowards(transform.position,targetF.transform.position, 0.04f);
transform.LookAt(targetF);
}
if (!firstPerson.GetComponent(CharacterController).active) {
transform.position = Vector3.MoveTowards(transform.position,targetT.transform.position, 0.09f);
transform.LookAt(targetT);
}
}