UnassignedReferenceException: The variable targetA of ‘TankModel_B1’ has not been assigned.
You probably need to assign the targetA variable of the TankModel_B1 script in the inspector.
TankModel_B1.Update () (at Assets/TankModel_B1.js:17)
whats wrong with this code ??? can run and work but got red line which show on above:
which i have put a Strong to it on the code below
var targetA : Transform;
var targetB : Transform;
private var currentTarget : Transform;
var proximity : float = 1.0;
var speed : float = 1.0;
//with function Start we set at start the current target
function Start ()
{
currentTarget = targetA;
}
function Update ()
{
var Distance : Vector3 = currentTarget.transform.position - transform.position;
//if “player” is “1” unit far, change currentTarget to next one
if(Distance.magnitude < proximity)
{
switch(currentTarget)
{
case targetA:
currentTarget = targetB;
break;
case targetB:
currentTarget = targetA;
break;
}
}
transform.position = Vector3.Slerp(transform.position, currentTarget.transform.position, Time.deltaTime * speed);
//make object look towards currentTarget
transform.LookAt(currentTarget);
}