示例#1
0
        //Is Called by any of the "StepTrigger" Script on a feet when they collide with the ground.
        public void EnterStep(StepTrigger foot)
        {
            if (!Tracks)
            {
                return;          //If there
            }
            RaycastHit footRay;

            if (foot.StepAudio && clips.Length > 0)                         //If the track has an AudioSource Component and whe have some audio to play
            {
                foot.StepAudio.clip = clips[Random.Range(0, clips.Length)]; //Set the any of the Audio Clips from the list to the Feet's AudioSource Component
                foot.StepAudio.Play();                                      //Play the Audio

                //Put a track and particles
                if (!foot.HasTrack)  // If we can put a track
                {
                    if (Physics.Raycast(foot.transform.position, -transform.up, out footRay, 1, GetComponent <Animal>().GroundLayer))
                    {
                        ParticleSystem.EmitParams ptrack = new ParticleSystem.EmitParams();
                        ptrack.rotation3D = (Quaternion.FromToRotation(-foot.transform.forward, footRay.normal) * foot.transform.rotation).eulerAngles; //Get The Rotation
                        ptrack.position   = new Vector3(foot.transform.position.x, footRay.point.y + trackOffset, foot.transform.position.z);           //Get The Position


                        Tracks.Emit(ptrack, 1);

                        if (Dust)
                        {
                            Dust.transform.rotation = (Quaternion.FromToRotation(-foot.transform.forward, footRay.normal) * foot.transform.rotation);
                            Dust.transform.Rotate(-90, 0, 0);
                            Dust.Emit(1);
                        }
                    }
                }
            }
        }
示例#2
0
        //Is Called by any of the "StepTrigger" Script on a feet when they collide with the ground.
        internal void EnterStep(StepTrigger foot)
        {
            if (!Active)
            {
                return;
            }

            if (Tracks && Tracks.gameObject.IsPrefab() && !instantiateTracks)         //If is a prefab clone it!
            {
                Tracks = Instantiate(Tracks, transform, false);
                Tracks.transform.localScale = Scale;
            }

            if (Dust && Dust.gameObject.IsPrefab())
            {
                Dust = Instantiate(Dust, transform, false);             //If is a prefab clone it!
                Dust.transform.localScale = Scale;
            }

            if (foot.StepAudio && clips.Length > 0)                         //If the track has an AudioSource Component and whe have some audio to play
            {
                foot.StepAudio.clip = clips[Random.Range(0, clips.Length)]; //Set the any of the Audio Clips from the list to the Feet's AudioSource Component
                foot.StepAudio.Play();                                      //Play the Audio
            }

            //Track and particles
            if (!foot.HasTrack)  // If we are ready to set a new track
            {
                if (Physics.Raycast(foot.transform.position, -transform.up, out RaycastHit footRay, 1, GroundLayer.Value))
                {
                    if (Tracks && !footRay.collider.attachedRigidbody)
                    {
                        if (instantiateTracks)
                        {
                            Instantiate(Tracks, new Vector3(foot.transform.position.x, footRay.point.y + trackOffset, foot.transform.position.z), Quaternion.identity);
                        }
                        else
                        {
                            ParticleSystem.EmitParams ptrack = new ParticleSystem.EmitParams
                            {
                                rotation3D = (Quaternion.FromToRotation(-foot.transform.forward, footRay.normal) * foot.transform.rotation).eulerAngles, //Get The Rotation
                                position   = new Vector3(foot.transform.position.x, footRay.point.y + trackOffset, foot.transform.position.z)            //Get The Position
                            };

                            Tracks.Emit(ptrack, 1);
                        }
                    }

                    if (Dust)
                    {
                        Dust.transform.position = new Vector3(foot.transform.position.x, footRay.point.y + trackOffset, foot.transform.position.z); //Get The Position
                        Dust.transform.rotation = (Quaternion.FromToRotation(-foot.transform.forward, footRay.normal) * foot.transform.rotation);
                        Dust.transform.Rotate(-90, 0, 0);
                        Dust.Emit(DustParticles);
                    }
                }
            }
        }
示例#3
0
        //Is Called by any of the "StepTrigger" Script on a feet when they collide with the ground.

        public void EnterStep(StepTrigger foot)
        {
            if (Tracks && !Tracks.gameObject.activeInHierarchy)         //If is a prefab clone it!
            {
                Tracks = Instantiate(Tracks, transform, false);
                Tracks.transform.localScale = Scale;
            }

            if (Dust && !Dust.gameObject.activeInHierarchy)
            {
                Dust = Instantiate(Dust, transform, false);             //If is a prefab clone it!
                Dust.transform.localScale = Scale;
            }

            if (!active)
            {
                return;
            }

            RaycastHit footRay;

            if (foot.StepAudio && clips.Length > 0)                         //If the track has an AudioSource Component and whe have some audio to play
            {
                foot.StepAudio.clip = clips[Random.Range(0, clips.Length)]; //Set the any of the Audio Clips from the list to the Feet's AudioSource Component
                foot.StepAudio.Play();                                      //Play the Audio
            }

            //Track and particles
            if (!foot.HasTrack)  // If we are ready to set a new track
            {
                if (Physics.Raycast(foot.transform.position, -transform.up, out footRay, 1, GetComponent <Animal>().GroundLayer))
                {
                    if (Tracks)
                    {
                        ParticleSystem.EmitParams ptrack = new ParticleSystem.EmitParams();
                        ptrack.rotation3D = (Quaternion.FromToRotation(-foot.transform.forward, footRay.normal) * foot.transform.rotation).eulerAngles; //Get The Rotation
                        ptrack.position   = new Vector3(foot.transform.position.x, footRay.point.y + trackOffset, foot.transform.position.z);           //Get The Position
                        Tracks.Emit(ptrack, 1);
                    }

                    if (Dust)
                    {
                        Dust.transform.position = new Vector3(foot.transform.position.x, footRay.point.y + trackOffset, foot.transform.position.z); //Get The Position
                        Dust.transform.rotation = (Quaternion.FromToRotation(-foot.transform.forward, footRay.normal) * foot.transform.rotation);
                        Dust.transform.Rotate(-90, 0, 0);
                        Dust.Emit(DustParticles);
                    }
                }
            }
        }