Hi, this is a continuation of the topic “How to teleport a object”, so I am trying to assign a object at runtime, but it doesn’t work at all and this is so frustrating and I just want it to work, how do I assign it at runtime correctly? My issue is that it doesn’t get assigned and I spawn at the center of the scene at 0, 0, 0.
Here’s my script:
var TactScript : ThrowTact;
static var Health : float = 100.0f;
var DefSpawn : Vector3;
var Tact = GameObject;
function Start () {
}
function Update () {
Tact = GameObject.FindGameObjectWithTag("Tact");
if(Health == 0 && TactScript.HasTact == true){
transform.localPosition = DefSpawn;
Health = 100;
}
else
if(Health == 0 && TactScript.HasTact == false){
transform.localPosition = Tact.transform.localPosition.up * 3;
Health = 100;
}
}