Beispiel #1
0
    void Death()
    {
        if (m_parent)
        {
            m_parent.OnItemsDeath(m_index);
        }

        Transform t    = Instantiate(m_spawnedItemPrefab, transform.position, transform.rotation);
        Rigidbody rb   = t.GetComponent <Rigidbody>();
        float     rStr = 20;
        float     pStr = 3;

        if (rb)
        {
            rb.AddTorque(new Vector3(Random.Range(-rStr, rStr), Random.Range(-rStr, rStr), Random.Range(-rStr, rStr)), ForceMode.VelocityChange);
            rb.AddForce(new Vector3(Random.Range(-pStr, pStr), 0, Random.Range(-pStr, pStr)), ForceMode.VelocityChange);
        }

        m_dying = true;
        Destroy(gameObject);
    }