Exemplo n.º 1
0
    public void AddExplosionForce(Vector3 explosionOrigin)
    {
        Vector3 direction = (explosionOrigin - transform.position).normalized;
        float   speed     = Random.Range(0.1f, 0.2f);
        Vector3 force;

        force.x = direction.x * speed;
        force.y = direction.y * speed;
        force.z = direction.z * speed;
        ballPhysics.applyForce(force);
    }
Exemplo n.º 2
0
 private void HandleSpecialInput(bool hit, Vector3 hitPosition, Vector3 faceDirection)
 {
     if (Input.GetKeyDown(KeyCode.Mouse2))
     {
         if (explosiveBallPrefab != null)
         {
             GameObject  explosiveBall = Instantiate(explosiveBallPrefab, transform.position + faceDirection + Vector3.up, Quaternion.identity) as GameObject;
             BallPhysics ballPhysics   = explosiveBall.GetComponent <BallPhysics>();
             Vector3     force         = faceDirection;
             float       tossSpeed     = 0.8f;
             force.x = force.x * tossSpeed;
             force.y = force.y * tossSpeed;
             force.z = force.z * tossSpeed;
             ballPhysics.applyForce(force);
         }
     }
 }
Exemplo n.º 3
0
    void Start()
    {
        destroyCountdown = 60 * 3;
        scaleDownTime    = 60 * 1;

        ballPhysics = GetComponent <BallPhysics>();

        Vector3 force;

        force.x = Random.Range(-0.02f, 0.02f);
        force.y = Random.Range(0.05f, 0.1f);
        force.z = Random.Range(-0.02f, 0.02f);
        ballPhysics.applyForce(force);

        Quaternion rotation    = transform.rotation;
        Vector3    eulerAngles = rotation.eulerAngles;

        eulerAngles.y        = Random.Range(0.0f, 360.0f);
        rotation.eulerAngles = eulerAngles;
        transform.rotation   = rotation;
    }