The problem I’m having is. I need to be able to generate Gameobjects with LineRenderers attached (or added to an empty Gameobject upon instantiation). I then want the newly instantiated LineRenderer object to reference some variables from the playerMover script which instantiated it.
I’ve seen examples where people use GameObject thePlayer = GameObject.Find(“ThePlayer”); OR PlayerScript playerScript = thePlayer.GetComponent();
but my issue is that the script which instantiates the linerenderer object is used on multiple objects in my game and the tags for each of these objects are often the same “Offense” or “Defense” so I’m concerned that using Find or GetComponent will pickup the wrong ‘parent’ (don’t think that’s the right use of parent but its a similar relationship).
I want the playerMover script to instantiate a new gameobject with linerenderer and then pass it a few variables. The variables can be passed to the new game object immediately in void Start()
Can someone show me some code which will work for this.