I’m in the process of neatening up my scripts to package it all together into one prefab, which basically consists of a main controller, a rocket launch system and some turrets.
So far, I’m working on getting the main controller to find a target and then assign it to the other components. Turrets work, the missile launcher will trigger based on the correct target.
However, the missiles are a different matter. They’re prefabs instantiated from a series of spawn points, and use their own targeting system. I’m attempting instead to pass the target to them from the controller.
In the script for my launcher, I have this:
var missileProjectile : Rigidbody = Instantiate(
projectile, slot.position, slot.rotation ); //create clone of projectile at the right position/orientation
missileProjectile.velocity =
transform.TransformDirection( Vector3.forward * speed ); //give it some speed
and then I attempt to pass it the target:
missileProjectile.GetComponent(missileHomingScript).missiletarget = LookAtTarget ;
Where missileHomingScript is the script attached to the prefab, and LookAtTarget is the name of the target.
Unity throws me this error:
Assets/Standard Assets/Scripts/Component Scripts/Weapon Component/multi_missile_launcher_script.js(88,40): BCE0005: Unknown identifier: ‘missileHomingScript’.
I’ve scoured every resource I can find, and I’m pretty certain that the syntax is correct. So why am I getting this error?