However I get an error saying randomScript cannot be found whenever I implement it in update. I know this is where I fall down because I just don’t know how to declare a script and this is nowhere in the docs other than scriptableObject and thts not what I want.
This is driving me nuts can anyone help me out here plz?
So to declare an instance of the script you want to access seems to be as follows
//declare the actual script and then the name you want to
//reference it as - usually just make the first letter lower or
//upper case in order to keep it clean.
public ScriptIWantToAccess scriptIWantToAccess;
Then within the “Start” function write the “referenced name” of the script not the actual script first and then use GetComponent to get the actual script as follows…
scriptIWantToAccess = cube.GetComponent<ScriptIWantToAccess >();
or
scriptIWantToAccess = cube.gameObject.GetComponent<ScriptIWantToAccess >();
Either should be fine however if your putting it on a camera I think it’s your camera object then same as up top otherwise it’s “.main.gameObject” and the rest as follows in the example for the GetComponent part.
Then finally you just call the instance name you made for the original script in update function or fixed update, OnGui etc and it should give you access to all the original scripts goodies