Beispiel #1
0
        void Start()
        {
            Transform transformForRigidBody = transform;

            while (transformForRigidBody != null && transformForRigidBody.rigidbody == null)
            {
                transformForRigidBody = transformForRigidBody.parent;
            }
            if (transformForRigidBody != null)
            {
                body = transformForRigidBody.rigidbody;
            }

            InitSlipMaxima();

            if (!UseEarthFX && SkidmarkObject != null)
            {
                Skids     = SkidmarkObject.GetComponentInChildren(typeof(RGKCar_Skidmarks)) as RGKCar_Skidmarks;
                SkidSmoke = SkidmarkObject.GetComponentInChildren(typeof(ParticleEmitter)) as ParticleEmitter;
            }
        }
Beispiel #2
0
        void CastFX(EarthFX.EarthFXData FX, RaycastHit SurfaceHitPoint)
        {
            /// BRAKE SKIDS
            if (FX.BrakeSkid != null && Mathf.Abs(this.slipRatio) > FX.BrakeSkidStartSlip)
            {
                Skids = FX.BrakeSkid.GetComponent(typeof(RGKCar_Skidmarks)) as RGKCar_Skidmarks;

                lastSkid = Skids.AddSkidMark(SurfaceHitPoint.point, SurfaceHitPoint.normal, Mathf.Abs(slipRatio), lastSkid);

                if (FX.BrakeSmoke != null)
                {
                    SkidSmoke = FX.BrakeSmoke.GetComponent(typeof(ParticleEmitter)) as ParticleEmitter;

                    SkidSmoke.Emit(
                        SurfaceHitPoint.point + new Vector3(UnityEngine.Random.Range(-0.1f, 0.1f),
                                                            UnityEngine.Random.Range(-0.1f, 0.1f),
                                                            UnityEngine.Random.Range(-0.1f, 0.1f)),                   //pos
                        new Vector3(this.slipVelo * 0.05f, 0),                                                        //vel
                        UnityEngine.Random.Range(SkidSmoke.minSize, SkidSmoke.maxSize) * Mathf.Clamp(0.5f, 1f, 1.5f), //size
                        UnityEngine.Random.Range(SkidSmoke.minEnergy, SkidSmoke.maxEnergy),                           //energy
                        Color.white);
                }
            }
            else
            {
                lastSkid = -1;
            }
            ///TRAIL SMOKE
            if (FX.TrailSmoke != null && Mathf.Abs(angularVelocity) > FX.TrailSmokeStartVelocity)
            {
                TrailSmoke = FX.TrailSmoke.GetComponent(typeof(ParticleEmitter)) as ParticleEmitter;

                TrailSmoke.Emit(
                    SurfaceHitPoint.point + new Vector3(UnityEngine.Random.Range(-0.1f, 0.1f),
                                                        UnityEngine.Random.Range(-0.1f, 0.1f),
                                                        UnityEngine.Random.Range(-0.1f, 0.1f)),
                    new Vector3(this.slipVelo * 0.05f, 1),
                    UnityEngine.Random.Range(TrailSmoke.minSize, TrailSmoke.maxSize) * Mathf.Clamp(0.5f, 1f, 1.5f),
                    UnityEngine.Random.Range(TrailSmoke.minEnergy, TrailSmoke.maxEnergy), Color.white);
            }
            ///TRAIL SKIDS
            if (FX.TrailSkid != null && Math.Abs(angularVelocity) > 5)
            {
                Trails    = FX.TrailSkid.GetComponent(typeof(RGKCar_Skidmarks)) as RGKCar_Skidmarks;
                lastTrail = Trails.AddSkidMark(SurfaceHitPoint.point, SurfaceHitPoint.normal, Mathf.Abs(1) - 0.2f, lastTrail);
            }
            else
            {
                lastTrail = -1;
            }
            ///SPLATTERS
            if (FX.Splatter != null && Math.Abs(angularVelocity) > 5 && !surfaceChanged)
            {
                Splatter = FX.Splatter.GetComponent(typeof(ParticleEmitter)) as ParticleEmitter;
                Splatter.Emit(
                    SurfaceHitPoint.point + new Vector3(UnityEngine.Random.Range(-0.2f, 0.2f),
                                                        UnityEngine.Random.Range(-0.1f, 0.2f),
                                                        UnityEngine.Random.Range(-0.1f, 0.1f)),
                    new Vector3(this.slipVelo * 0.05f, 0),
                    UnityEngine.Random.Range(Splatter.minSize, Splatter.maxSize),
                    UnityEngine.Random.Range(Splatter.minEnergy, Splatter.maxEnergy), Color.white);
            }
            ///DRIVE SOUND
            if (FX.SurfaceDriveSound != null)
            {
                SurfaceSound = FX.SurfaceDriveSound;
            }
            else
            {
                SurfaceSound = null;
            }

            ///BRAKE SOUND
            if (FX.BrakeSound != null)
            {
                BrakeSound = FX.BrakeSound;
            }
            else
            {
                BrakeSound = null;
            }

            ///FORWARDGRIP LOSE PERCENT
            if (FX.ForwardGripLosePercent > 0)
            {
                wheelGrip = definedGrip - (definedGrip * (FX.ForwardGripLosePercent / 100f));
            }
            else
            {
                wheelGrip = definedGrip;
            }

            ///SIDEGRIP LOSE PERCENT
            if (FX.SidewaysGripLosePercent > 0)
            {
                sideGrip = definedSideGrip - (definedSideGrip * (FX.SidewaysGripLosePercent / 100f));
            }
            else
            {
                sideGrip = definedSideGrip;
            }

            ///DRAG
            SurfaceAngularDrag = FX.AngularDrag;
            SurfaceForwardDrag = FX.ForwardDrag;
        }