Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class CubeScript : MonoBehaviour {
- private float randX, randY, randZ;
- private float randForceX, randForceY, randForceZ;
- private float maxForce = 250;
- private float minForce = -250;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update ()
- {
- if (gameObject.transform.position.y <= -8)
- {
- randX = Random.Range(-4.8f, 4.8f);
- randY = Random.Range(0.58f, 10f);
- randZ = Random.Range(-4.8f, 4.8f);
- gameObject.transform.position = new Vector3(randX, randY, randZ);
- }
- }
- void OnMouseDown()
- {
- randForceX = Random.Range(minForce, maxForce);
- randForceY = Random.Range(minForce, maxForce);
- randForceZ = Random.Range(minForce, maxForce);
- gameObject.rigidbody.AddForce(new Vector3(randForceX, randForceY, randForceZ));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment