CTIN 289 - Interactive Snippets Library

Powered by 🌱Roam Garden

References

GameObject newThing = Instantiate(thingPrefab, position, rotation);

newThing.transform.parent = gameObject.transform;
newThing.GetComponent<Renderer>().enabled = false;

// How to get a script component from a newly instantiated object and call a method on it
GameObject newMissleGO = Instantiate(misslePrefab);
HomingMissle newMissile = newMissleGO.GetComponent<HomingMissle>();
newMissle.SetTarget(player);