Hi, I have a ship tagged “Player” that gets followed by the boomer objects, that part works perfectly, and when the player loads the cargo, tag changes to “ShipLoaded” as intended, but the boomers no longer follow the player, even tho I specified to choose from tags “Player” || “ShipLoaded”, and the console reports NullReferenceException error in OnTriggerStay, on the “var targ” line.
What am I doing wrong?
#pragma strict
var speed : float = 4;
var closeEnough : boolean = false;
function Start()
{
}
function Update()
{
}
function OnTriggerStay(trig : Collider)
{
rigidbody.isKinematic = false;
if(((trig.gameObject.tag == "Player") || (trig.gameObject.tag == "ShipLoaded")) && (closeEnough == false))
{
var targ = GameObject.FindWithTag("Player" || "ShipLoaded");
transform.position = Vector3.MoveTowards(transform.position, targ.transform.position, speed * Time.deltaTime);
}
}
function OnTriggerExit(trig : Collider)
{
rigidbody.isKinematic = true;
}