Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Bola : MonoBehaviour {
- public Rigidbody2D corpoDaBola;
- public Rigidbody2D PlayerUm;
- public float VelBolax;
- public float VelBolay;
- // Use this for initialization
- void Start () {
- PlayerUm = GetComponent<Rigidbody2D> ();
- corpoDaBola = GetComponent<Rigidbody2D> ();
- corpoDaBola.AddForce (new Vector2(0.05f,0.05f));
- }
- // Update is called once per frame
- void Update () {
- VelBolax = corpoDaBola.velocity.x;
- VelBolay = corpoDaBola.velocity.y;
- }
- void OnCollisionEnter2D (Collision2D colisao){
- if ((colisao.gameObject.tag == "Player")){
- if ((VelBolax < 19f) && (VelBolax > -19f) && (VelBolay < 19f) && (VelBolay > -19f)) {
- corpoDaBola.velocity = corpoDaBola.velocity + PlayerUm.velocity / 10;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement