コード例 #1
0
    public void Update()
    {
        if (IsAutoPilot())
        {
            Throttle      = autoPilot.GetThrottle();
            SteeringPitch = autoPilot.GetPitch();
            SteeringRoll  = autoPilot.GetRoll();
            SteeringYaw   = autoPilot.GetYaw();
            WheelBreaks   = autoPilot.GetBrake();
        }
        else
        {
            Throttle      = input.GetThrottle();
            SteeringPitch = input.GetPitch();
            SteeringRoll  = input.GetRoll();
            SteeringYaw   = input.GetYaw();
            WheelBreaks   = input.GetBreak();
        }
        Throttle      = Mathf.Clamp01(Throttle);
        SteeringPitch = Mathf.Clamp(SteeringPitch, -1, 1);
        SteeringRoll  = Mathf.Clamp(SteeringRoll, -1, 1);
        SteeringYaw   = Mathf.Clamp(SteeringYaw, -1, 1);

        WheelMaterial.dynamicFriction = wheelBrakeBaseDynamicFriction * (WheelBreaks ? WheelBrakeMultiplier : 1);
        WheelMaterial.staticFriction  = wheelBrakeBaseStaticFriction * (WheelBreaks ? WheelBrakeMultiplier : 1);

        if (Input.GetKeyDown("o"))
        {
            environment.ToggleWind();
        }

        if (Input.GetKeyDown("l"))
        {
            AerobaticSmoke = !AerobaticSmoke;
            SetSmokeEmmiters();
        }

        foreach (AeroEngine engine in physics.engines)
        {
            fuelLevel -= engine.FuelConsumption * Time.deltaTime * fuelConsumptionMultiplier;
        }
    }