Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class BallControl : MonoBehaviour {
- int waitSeconds = 2;
- // Use this for initialization.
- void Start ()
- {
- hi(20f);
- GoBall();
- }
- IEnumerator hi(float secs)
- {
- yield return new WaitForSeconds(secs);
- }
- // Generates random value, and decides which way to knock the ball based on it.
- void GoBall ()
- {
- float rand = Random.Range(0.0f, 100.0f);
- if (rand < 50.0f)
- {
- Rigidbody2D.AddForce(new Vector2(20.0f, 15.0f));
- }
- else
- {
- Rigidbody2D.AddForce(new Vector2(-20.0f, -15.0f));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement