Beispiel #1
0
    /*  // Use this for initialization
     * void Start()
     * {
     *
     * }
     *
     */

    // Update is called once per frame
    void Update()
    {
        // slow down in a turn
        float decclerationThres = 0.3f;

        if (Mathf.Abs(frontLeft.GetComponent <WheelCollider>().steerAngle) > decclerationThres * maxSteerAngle || Mathf.Abs(frontRight.GetComponent <WheelCollider>().steerAngle) > decclerationThres * maxSteerAngle)
        {
            float deccelerationRatio = 1.2f * Mathf.Max(Mathf.Abs(frontLeft.GetComponent <WheelCollider>().steerAngle), Mathf.Abs(frontRight.GetComponent <WheelCollider>().steerAngle)) / maxSteerAngle;
            status.decreaseTopSpeedModifier(deccelerationRatio);
        }
        if (!stopFlag && !stoppedBySkill)
        {
            reSpawnTimer += Time.deltaTime;
            if (reSpawnTimer > reSpawnTime)
            {
                respawn();
            }
        }



        limitAngleAndVelocity();
    }