In Unity, I want one object to have a falling speed variable that all the other objects can access. For various reasons, I can\'t use the inbuilt gravity for what I\'m tryin
if it is in the fixedUpdate – Martin j
seems like it works well in Awake too. Both scripts are added to the same GameObject.
public class FirstScript : MonoBehaviour {
protected internal GameObject myobject;
private void Awake() {
myobject = (GameObject)Instantiate(Resources.Load("nameofprefab"));
myobject.transform.parent = gameObject.transform;
...
public class SecondScript : MonoBehaviour {
private GameObject myobject;
private void Awake() {
myobject = gameObject.GetComponent().myobject;
myobject.SetActive(false); //for example
...