Advertisement
Guest User

ball script

a guest
Aug 4th, 2015
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ball : MonoBehaviour {
  5.  
  6.     public Rigidbody2D rb;
  7.  
  8.     void Start ()
  9.     {
  10.         this.GetComponent<Rigidbody2D>().AddForce (-transform.up * 100f);
  11.     }
  12.  
  13.     void Update ()
  14.     {
  15.         if ((transform.position.x > 9.40f) || (transform.position.x < -9.40f))
  16.         {
  17.             transform.position=new Vector2(0.0f,0.0f);
  18.         }
  19.         if ((transform.position.y > 5.55f) || (transform.position.y < -5.55f))
  20.         {
  21.             transform.position=new Vector2(0.0f,0.0f);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement