If i instantiate a script containing Start()
and Update()
function, will start and update function will work as they are supposed to ?, Also,which gameObject will they be associated with ?
A monobehaviour script can not live without a Gamobject.
You can do : (Player is the name of the script)
GameObject myplayer = new GameObject (“Player”);
or
GameObject myplayer = new GameObject ();
myplayer.AddComponent (“player”);
I don’t think you can just instantiate a script (haven’t tested this tho).
What you need to do, is create an empty gameObject, attach the script to it, save as prefab, instantiate the prefab.
Just in case it is possible to instantiate a script, I’m guessing it will auto create an empty gameObject (really don’t think it’s possible tho).
And for the other part of your question, I think the start/update function will work regardless.