Throwing Objects

Ok so I want to throw objects randomly on a board - So they all land in random places.

I have attempted a script but it is a little to embarrassing as I’m not the best
programmer yet.

Any help will be very helpful. Just looking for a starting script that I can play with.


var projectile : Transform;
var projectile2 : Transform;
function Update () {
    if (Input.GetButtonDown("Fire1")) {
    // Instantiate the projectile at the position and rotation of this transform
    var clone : Transform;
    var clone2 : Transform;
    var clone3 : Transform;
    clone = Instantiate(projectile, transform.position, transform.rotation);
    clone2 = Instantiate(projectile2, transform.position, transform.rotation);
    // Add force to the cloned object in the object's forward direction
    clone.rigidbody.AddForce(clone.transform.forward * 400);
    clone2.rigidbody.AddForce(clone.transform.forward * 400);


Your post (as it appears now) isn’t something we can give you a quick answer for, and isn’t really appropriate for UnityAnswers. The UnityAnswers philosophy is:

“[Unity Answers] is a place to ask specific questions that have specific answers. The forum is a better place to post discussions and non-technical questions.”

It sounds like what you’re looking for is Unity training, rather than a specific answer. I would suggest visiting the following training websites to find the one that best helps you move forward. In addition to the sites below, you can always search YouTube, which has a large number of user-created Unity tutorials.

There is absolutely no way you’re still working on the same issue, but this is for anyone who needs to see this. You could try adding a force to the rigidbody component of whatever object you want to be thrown. For example, if a certain button is pressed, a force would be added to the rigidbody causing it to move forward.
using UnityEngine;

public class ThrowingObject : MonoBehaviour {

	public Rigidbody rigidBody;
	public float forwardForce = 2000f;

	void FixedUpdate ()
		if (Input.GetKey("Fire1"))
			rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0);

This could work.