示例#1
0
    void OnCollisionEnter(Collision col)
    {
        Bola bola = col.gameObject.GetComponent <Bola>();

        if (bola != null)
        {
            float velx = 10 + (10 * Random.value) * ((Random.Range(0, 1) * 2 - 1));
            float velz = 10 + (10 * Random.value) * ((Random.Range(0, 1) * 2 - 1));

            Vector3 impulsoIni = new Vector3(velx, 0, velz);

            bola.transform.position = new Vector3(0f, (float)0.8, 0f);

            bola.GetComponent <Rigidbody>().velocity        = Vector3.zero;
            bola.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
            bola.GetComponent <Rigidbody>().AddForce(impulsoIni, ForceMode.Impulse);

            if (jugador == ePlayer.Right)
            {
                puntaje.puntaje2++;
            }
            else if (jugador == ePlayer.Left)
            {
                puntaje.puntaje1++;
            }
        }
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     sizeBola   = bola.GetComponent <Renderer>().bounds.size;
     position.x = Screen.width - 10;
     position.y = Screen.height - 10;
     transform.GetComponent <RectTransform>().sizeDelta = sizeBola * (Screen.width / 16);
     transform.position = position;
 }
示例#3
0
 // Use this for initialization
 void Start()
 {
     sizeBola   = bola.GetComponent <Renderer>().bounds.size;
     position.x = (Screen.width / 2);
     position.y = (Screen.height / 2) / 1.5f;
     transform.GetComponent <RectTransform>().sizeDelta = sizeBola * (Screen.width / 12);
     transform.position = position;
 }
示例#4
0
 // Use this for initialization
 void Start()
 {
     t          = GetComponent <Text>();
     sizeBola   = bola.GetComponent <Renderer>().bounds.size;
     position.x = 20;
     position.y = Screen.height - 20;
     //transform.GetComponent<RectTransform>().sizeDelta = sizeBola * (Screen.width / 16);
     transform.position = position;
     t.fontSize         = Screen.width / 8;
 }
示例#5
0
 // Metodo start é executado apenas na criação do objeto
 void Start()
 {
     bola.GetComponent <Rigidbody>().useGravity = false;
 }