Hey everyone! I have a question I have had for awhile now. I am trying to make a script that makes balls fall from the top of my screen continuously and they keep falling until one of them touches the bottom of the screen and then the game over box pops up. I also have 4 different colors and I want it to pick a different color ball every time one of them falls. Thanks for the help!
attach this to either the spheres or the other object that it collides with, then attach a RigidBody component to the sphere and check gravity is cheched on. the other object needs to have IsTrigger ticked on so that it can detect the other object. Code (CSharp): using UnityEngine; using System.Collections; public class ChangeScene : MonoBehaviour { void OnCollisionEnter (Collision col) { if(col.gameObject.name == "FallingObject") { Application.LoadLevel ("GameOver"); } } } When a collision between two Colliders occurs and if at least one of them has a Rigidbody attached, three collision messages are sent out to the objects attached to them. These events can be handled in scripting, and allow you to create unique behaviors with or without making use of the built-in NVIDIA PhysX engine.
You could also use the shuriken particle system, where you can set the colour to vary etc. and also get collision messages out of the box Just another approach!
Thanks for your help everyone! Everything is working fine. Except I just dont know how to make the infinite spawn script that spawns random balls infinitely.
Hey brother, I am trying to work on something similar, I was wondering if you can share your script of balls falling with different color?