How to make objects falling down from the top of the scene?

I am trying to make a game and need help. I want to make game where coins are falling down and you click to collect. I am using C#, but I can familiarize myself with JavaScript. I am new to the unity community and seeking help from anyone who knows what they are doing. Any help is much appreciated. Thanks.

Complete 3 minute guide to a falling block avoiding game.

Then you'll need "object picking" as a search term to work out if you're clicking an object.

This is not that hard a script as they’re making it out to be, and it would benefit any beginner to find this solution. I know I would have wanted a simple answer like this when I started.

Make your coin in Unity (create cylinder then scale it, etc.). Set your material and make it a prefab so you can easily update it later.

Then attach a script to your coin. Call it “coinCollect”.

Open that script and paste this code in:

using UnityEngine;
using System.Collections;

public class coinCollect : MonoBehaviour {

	public float fallSpeed = 8.0f;
	public float spinSpeed = 250.0f;

	void Update() {

		transform.Translate(Vector3.down * fallSpeed * Time.deltaTime, Space.World);
		transform.Rotate(Vector3.forward, spinSpeed * Time.deltaTime);

	}

	void OnMouseDown() {

		renderer.enabled = false;

	}

}

Oh, and then don’t forget to put your camera to where it can see the coin falling.

Press play, done.

Notes: “renderer.enabled = false” just makes the coin invisible when it’s clicked. That way you can reuse the same coin by resetting the visibility after putting it back at the top of the screen when it hits a lower boundary (otherwise do a search on “Destroy” to remove the coin permanently if you don’t want to recycle it). After that line, you could optionally play a sound effect for when the coin is clicked. Also, regarding the lower boundary, you should put a simple “if” statement in the Update function so that the coin doesn’t just fall forever. Basically saying, “if the coin’s y position is past the the lower limit, put the coin back to the top”.

From your question, it appears you are a complete newbie… There is a long learning cycle in front of you… Anyhow, It must be fun trying to explain soo basic…

  • You must first get your model (coin) ready, complete with rigidbody (To respond to gravity). Usually Blender or somethign should work, but in yoru case, a unity “Cylinder” should be adequate)
  • create your basic scene, a plane (or terrain) on which your coin can fall
  • Either statically place lots of your coins at a height (this will need no scripting to make the coins fall. You just have to start the game.)(OR)
  • Create a manager (An empty Object will do) and add a script to it to instantiate the coin at preset or random positions beyond a given height, and watch them fall down.

Collecting them… is a different story altogether. You need to get deeper into scripting and the unity API calls. Depending on what exactly you want, it could be anywhere from a few lines to a few files. Happy Learning!!!