How can I feed my missiles guide laser target pos?

I have a ship.
It shoots missiles by instantiating a prefab.
I also has a guide laser that raycasts to generate a target position.

My question is how do I best pass on this target position to all living missiles?

Any tips for how to structure that?
(Without going OOP crazy :slight_smile:

Your question is far too vague. Information on using Unity Answers : * http://answers.unity3d.com/page/newuser.html * http://video.unity3d.com/video/7720450/tutorials-using-unity-answers Every time you create a missile, put it in a list. Then when you select a target, tell every missile in the list what the target is. Generic List : http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use?#Generic_List

–

Thanks that looks like a handy list description.

–

1 Answer

1

SetTarget(Vector3 Position)
{
GameObject Missiles = GameObject.FindGameObjectsWithTag(“Missile”);

foreach(GameObject m in Missiles)
m.SetEnemyPosition(Position);

}

Hope this helps! :slight_smile:

Ok thanks that should work. How can I dynamically tell the 'laser turret' that does the raycast to generate target pos, what tag to look for? And different ships' missiles need different tags do differentiate them. I will have a handful of different clones of the ship, enemy and player ships and they need to use the same c# scripts. Maybe they can take their tag from a 'parent node' that is linked to both missile generator and laser turret through the inspector?

–