Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class BALL : MonoBehaviour {
- public float InitialForce = 100f;
- Vector3 initVelocity = new Vector3();
- void Start()
- {
- Launch ();
- }
- // Use this for initialization
- void Launch ()
- {
- initVelocity.x = Random.Range(-1f,1f);
- initVelocity.y = Random.Range(-1f,1f);
- initVelocity.Normalize ();
- if
- (Mathf.Abs (initVelocity.x) < Mathf.Abs(initVelocity.y))
- {
- float x = initVelocity.x ;
- initVelocity.x = initVelocity.y ;
- initVelocity.y = x;
- }
- rigidbody.AddForce(initVelocity * InitialForce);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement