Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

1

Unity has a struct named Scene. From Scene you can get all of the root GameObjects of this particular scene. Note that the code is not tested. public static class SceneExtensions { public static void GetAllGameObjects(this Scene scene, out List<GameObject> allGameObjects) { GameObject[] rootGameObjects = scene.GetRootGameObjects(); ...


1

Since you have your OnTriggerEnter2D function in this script, it looks like this is the script you're placing on each individual coin. That means that each individual coin has its own copy of the coins variable. So you're not accumulating a total of how many coins are collected in your whole scene, you're just counting how many times this coin was ...


2

When you change scenes, the camera gets destroyed Because the camera gets destroyed (and the new scene has a new one) your cam variable no longer points to the main camera. You can detect this and do the appropriate thing, void Update () { if(cam == null) cam = Camera.main float dist = cam.transform.position.x * parallaxEffect; transform....


0

Like it says. "You need to set variable cam in inspector". To do this: In Hierarchy panel right and click choose "Create Empty" to add a new Game Object and rename it as ParralaxController (you can give any name you want). In Inspector panel press Add Component and type Parralax then choose the Parralax script below. When this ParralaxController is ...


Top 50 recent answers are included