Ejemplo n.º 1
0
        public void Update(VehicleController vc)
        {
            if (!enabled)
            {
                return;
            }

            if (solidAxle)
            {
                if (axleBones.Count == vc.axles.Count && axleBones != null)
                {
                    for (int i = 0; i < axleBones.Count; i++)
                    {
                        // Adjust axle position
                        Axle axle = vc.axles[i];

                        Vector3 position = (axle.leftWheel.WheelController.springTravelPoint + axle.rightWheel.WheelController.springTravelPoint) / 2f;
                        axleBones[i].position = position;
                        axleBones[i].LookAt(axle.leftWheel.WheelController.springTravelPoint, vc.transform.up);
                        axleBones[i].Rotate(0, 90, 0);

                        // Adjust camber
                        float camberAngle = VehicleController.AngleSigned(vc.transform.right, axleBones[i].right, vc.transform.forward);
                        axle.leftWheel.WheelController.SetCamber(camberAngle);
                        axle.rightWheel.WheelController.SetCamber(-camberAngle);
                    }
                }
                else
                {
                    Debug.LogError("Number of axle bones must be the same as the number of axles.");
                }
            }
            else
            {
                if (wheelBones.Count == vc.Wheels.Count && wheelBones != null)
                {
                    for (int i = 0; i < wheelBones.Count; i++)
                    {
                        wheelBones[i].position = vc.Wheels[i].WheelController.springTravelPoint;
                    }
                }
                else
                {
                    Debug.LogError("Number of wheel bones must be the same as the number of wheels.");
                }
            }
        }
Ejemplo n.º 2
0
        public void Update(VehicleController vc)
        {
            // Drift assist
            if (intensity > 0)
            {
                Vector3 normVel    = vc.vehicleRigidbody.velocity.normalized;
                Vector3 vehicleDir = vc.transform.forward;
                float   driftAngle = VehicleController.AngleSigned(normVel, vehicleDir, vc.transform.up);
                driftAngle = Mathf.Sign(driftAngle) * Mathf.Clamp(Mathf.Abs(Mathf.Clamp(driftAngle, -90f, 90f)), 0f, Mathf.Infinity);

                if (vc.axles.Count > 0)
                {
                    Axle    a        = vc.axles[vc.axles.Count - 1];
                    Vector3 center   = (a.leftWheel.ControllerTransform.position + a.rightWheel.ControllerTransform.position) / 2f;
                    float   forceMag = driftAngle * Mathf.Lerp(0f, vc.vehicleRigidbody.mass, vc.Speed / 15f) * intensity;
                    Vector3 force    = vc.transform.right * forceMag;
                    vc.vehicleRigidbody.AddForceAtPosition(force, center);
                }
            }
        }
Ejemplo n.º 3
0
        private void Redraw()
        {
            vc = vehicleChanger.ActiveVehicleController;
            if (vc == null)
            {
                return;
            }

            xOffset = startXOffset;
            yOffset = startYOffset;

            AddTitle("Engine");
            AddSettings(vc.engine);
            AddSettings(vc.engine.forcedInduction);

            AddTitle("Transmission");
            AddSettings(vc.transmission);

            AddTitle("Steering");
            AddSettings(vc.steering);

            AddTitle("Driving Assists");
            AddTitle("TCS", true);
            AddSettings(vc.drivingAssists.tcs);
            AddTitle("ABS", true);
            AddSettings(vc.drivingAssists.abs);
            AddTitle("Stability", true);
            AddSettings(vc.drivingAssists.stability);
            AddTitle("Drift Assist", true);
            AddSettings(vc.drivingAssists.driftAssist);

            // Display axles
            for (int i = 0; i < 2; i++)
            {
                NewColumn();
                Axle axle = vc.axles[i];
                if (axle == null)
                {
                    return;
                }
                AddTitle("Axle " + i);
                AddSettings(axle);
                AddSettings(axle.geometry);

                AddTitle("Left Wheel, Axle " + i, true);
                AddSettings(axle.leftWheel.wheelController);
                AddSettings(axle.leftWheel.wheelController.wheel);
                AddSettings(axle.leftWheel.wheelController.spring);
                AddSettings(axle.leftWheel.wheelController.damper);
                AddSettings(axle.leftWheel.wheelController.fFriction);
                AddSettings(axle.leftWheel.wheelController.sFriction);

                AddTitle("Right Wheel, Axle " + i, true);
                AddSettings(axle.rightWheel.wheelController);
                AddSettings(axle.rightWheel.wheelController.wheel);
                AddSettings(axle.rightWheel.wheelController.spring);
                AddSettings(axle.rightWheel.wheelController.damper);
                AddSettings(axle.rightWheel.wheelController.fFriction);
                AddSettings(axle.rightWheel.wheelController.sFriction);
            }
        }