コード例 #1
0
 /// <summary>
 /// Reset race values such as skidmarks, vehicle damage, etc
 /// </summary>
 private void ResetRaceValues()
 {
     if (GameObject.FindObjectOfType(typeof(Skidmark)))
     {
         Skidmark skidmarks = GameObject.FindObjectOfType(typeof(Skidmark)) as Skidmark;
         skidmarks.ClearSkidmarks();
     }
 }
コード例 #2
0
ファイル: Wheels.cs プロジェクト: joseedsonamorim/JogoCorrida
        void SetupWheelComponents()
        {
            if (!wheelCollider)
            {
                wheelCollider = GetComponent <WheelCollider>();
            }

            //Get the skidmarks object
            if (GameObject.FindObjectOfType(typeof(Skidmark)))
            {
                skidmarks = GameObject.FindObjectOfType(typeof(Skidmark)) as Skidmark;
            }

            //Configure the sound
            if (GetComponent <AudioSource>())
            {
                skidAudioSource = GetComponent <AudioSource>();
            }

            if (skidAudioSource)
            {
                skidAudioSource.spatialBlend = 1.0f;
                skidAudioSource.loop         = true;
            }


            //Instantiate all particles as child objects
            if (surfaceManager.terrainSurfaceTypes.Count > 0)
            {
                for (int i = 0; i < surfaceManager.terrainSurfaceTypes.Count; i++)
                {
                    if (surfaceManager.terrainSurfaceTypes[i].skidParticle)
                    {
                        if (!wheelParticleChildren.Contains(surfaceManager.terrainSurfaceTypes[i].skidParticle.transform.name + "(Clone)")) //make sure that theres no duplicates
                        {
                            GameObject particle = (GameObject)Instantiate(surfaceManager.terrainSurfaceTypes[i].skidParticle, transform.position, Quaternion.identity);
                            particle.transform.parent = transform;
                            var em = particle.GetComponent <ParticleSystem>().emission;
                            em.enabled = false;
                            wheelParticleChildren.Add(particle.transform.name);
                        }
                    }
                }
            }


            if (surfaceManager.physicMaterialSurface.Count > 0)
            {
                for (int i = 0; i < surfaceManager.physicMaterialSurface.Count; i++)
                {
                    if (surfaceManager.physicMaterialSurface[i].skidParticle)
                    {
                        if (!wheelParticleChildren.Contains(surfaceManager.physicMaterialSurface[i].skidParticle.transform.name + "(Clone)")) //make sure that theres no duplicates
                        {
                            GameObject particle = (GameObject)Instantiate(surfaceManager.physicMaterialSurface[i].skidParticle, transform.position, Quaternion.identity);
                            particle.transform.parent = transform;
                            var em = particle.GetComponent <ParticleSystem>().emission;
                            em.enabled = false;
                            wheelParticleChildren.Add(particle.transform.name);
                        }
                    }
                }
            }
        }