Ejemplo n.º 1
0
        // Spawn HitEffect
        public static void SpawnHitEffect(HitEffect hitObject, RaycastHit hit, bool showHitTexture = false)
        {
            if (hit.collider == null || hit.collider.isTrigger)
            {
                return;
            }

            if (hitObject == null)
            {
                Debug.LogError("ERROR: Decal Object is not setup!");
                return;
            }

            Texture        hitTexture  = hitObject.generic.hitTexture;
            AudioClip      hitSound    = hitObject.generic.hitSound;
            ParticleSystem hitParticle = hitObject.generic.hitParticle;

            int tmpIndex = SurfaceDetector.GetSurfaceIndexByHit(hit);

            foreach (SurfaceData sur in hitObject.surfaces)
            {
                if (sur.index == tmpIndex)
                {
                    hitTexture  = sur.hitTexture;
                    hitSound    = sur.hitSound;
                    hitParticle = sur.hitParticle;
                    break;
                }
            }

            HitEffect tmpHitObject = hitObject.SpawnCopy(hit.point + hit.normal * .0003f, Quaternion.FromToRotation(Vector3.forward, hit.normal));

            tmpHitObject.Configure(showHitTexture ? hitTexture : null, hitSound, hitParticle);
            tmpHitObject.transform.SetParent(hit.transform);
        }
Ejemplo n.º 2
0
        // GetSurface ByHit
        private SurfaceData GetSurfaceByHit(RaycastHit hit)
        {
            m_Audio.outputAudioMixerGroup = GameSettings.SFXOutput;
            m_Audio.pitch = Time.timeScale;

            int tmpIndex = SurfaceDetector.GetSurfaceIndexByHit(hit);

            foreach (SurfaceData sur in surfaces)
            {
                if (sur.index == tmpIndex)
                {
                    return(sur);
                }
            }

            return(generic);
        }