示例#1
0
    void OnCollisionEnter(Collision col)
    {
        if (col.transform.gameObject.tag == "Terrain" && gameController.LandingPressed)
        {
            Debug.Log("COLIDED WITH = " + col.transform.gameObject.name);
            gameController.UpdateFlightStatus(true, false, "TERRAINLND", false);
            groundLandingCollider.gameObject.transform.position = this.transform.position;
            //gameController.LandingPressed = false;
            //gameController.getShipStatus ();
        }

        if (col.relativeVelocity.magnitude < 2.5f)
        {
            return;
        }

        if (crashSounds.Length > 0)
        {
            crashSoundSource       = RHC_CreateAudioSource.NewAudioSource(gameObject, "Crash Sound", 5f, 1f, crashSounds[Random.Range(0, crashSounds.Length)], false, false, true);
            crashSoundSource.pitch = Random.Range(.85f, 1f);
            crashSoundSource.Play();
        }

        CollisionParticles(col.contacts[0].point);

        if (useDamage)
        {
            CollisionParticles(col.contacts[0].point);

            Vector3 colRelVel = col.relativeVelocity;
            colRelVel *= 1f - Mathf.Abs(Vector3.Dot(transform.up, col.contacts[0].normal));

            float cos = Mathf.Abs(Vector3.Dot(col.contacts[0].normal, colRelVel.normalized));

            if (colRelVel.magnitude * cos >= minimumCollisionForce)
            {
                sleep = false;

                localVector = transform.InverseTransformDirection(colRelVel) * (damageMultiplier / 50f);

                if (originalMeshData == null)
                {
                    LoadOriginalMeshData();
                }

                for (int i = 0; i < deformableMeshFilters.Length; i++)
                {
                    DeformMesh(deformableMeshFilters[i].mesh, originalMeshData[i].meshVerts, col, cos / deformableMeshFilters[i].transform.lossyScale.x, deformableMeshFilters[i].transform, rot, deformableMeshFilters[i].transform.lossyScale.x);
                }
            }
        }
    }
示例#2
0
    void OnCollisionEnter(Collision col)
    {
        if (col.relativeVelocity.magnitude < 2.5f)
        {
            return;
        }

        if (crashSounds.Length > 0)
        {
            crashSoundSource       = RHC_CreateAudioSource.NewAudioSource(gameObject, "Crash Sound", 5f, 1f, crashSounds[Random.Range(0, crashSounds.Length)], false, false, true);
            crashSoundSource.pitch = Random.Range(.85f, 1f);
            crashSoundSource.Play();
        }

        CollisionParticles(col.contacts[0].point);

        if (useDamage)
        {
            CollisionParticles(col.contacts[0].point);

            Vector3 colRelVel = col.relativeVelocity;
            colRelVel *= 1f - Mathf.Abs(Vector3.Dot(transform.up, col.contacts[0].normal));

            float cos = Mathf.Abs(Vector3.Dot(col.contacts[0].normal, colRelVel.normalized));

            if (colRelVel.magnitude * cos >= minimumCollisionForce)
            {
                sleep = false;

                localVector = transform.InverseTransformDirection(colRelVel) * (damageMultiplier / 50f);

                if (originalMeshData == null)
                {
                    LoadOriginalMeshData();
                }

                for (int i = 0; i < deformableMeshFilters.Length; i++)
                {
                    DeformMesh(deformableMeshFilters[i].mesh, originalMeshData[i].meshVerts, col, cos / deformableMeshFilters[i].transform.lossyScale.x, deformableMeshFilters[i].transform, rot, deformableMeshFilters[i].transform.lossyScale.x);
                }
            }
        }
    }
示例#3
0
 void SoundsInit()
 {
     engineSoundSource = RHC_CreateAudioSource.NewAudioSource(gameObject, "Engine Sound", 5f, 1f, engineSound, true, true, false);
 }
示例#4
0
 void SoundsInit()
 {
     fireSoundSource = RHC_CreateAudioSource.NewAudioSource(gameObject, "Laser Sound", 5f, 1f, fireSound, false, false, false);
 }