Ejemplo n.º 1
0
    public void FixedUpdate()
    {
        rb.AddForce(-rb.velocity.magnitude / 10 * transform.up, ForceMode.Acceleration);

        if (rb.velocity.magnitude < minVelocityThreshold)
        {
            rb.velocity = Vector3.zero;
            im.SetIsDriving(false);
        }

        foreach (AxleInfo axleInfo in axleInfos)
        {
            if (axleInfo.steering)
            {
                //axleInfo.leftWheel.steerAngle = steering;
                //axleInfo.rightWheel.steerAngle = steering;
            }
            if (axleInfo.oppositeSteering)
            {
                //axleInfo.leftWheel.steerAngle = -steering;
                //axleInfo.rightWheel.steerAngle = -steering;
            }
            if (axleInfo.motor)
            {
                //axleInfo.leftWheel. motorTorque = motor;
                //axleInfo.rightWheel.motorTorque = motor;
            }
            ApplyLocalPositionToVisuals(axleInfo.leftWheel);
            ApplyLocalPositionToVisuals(axleInfo.rightWheel);
        }
    }
Ejemplo n.º 2
0
    public void FixedUpdate()
    {
        //ensure the car stays on the ground
        if (CheckWheelsGrounded())
        {
            rb.AddForce(-rb.velocity.magnitude / 10 * transform.up, ForceMode.Acceleration);
        }

        //stop the car velocity if it is low
        if (rb.velocity.magnitude < minVelocityThreshold)
        {
            StopCarForce();
            im.SetIsDriving(false);
        }

        foreach (AxleInfo axleInfo in axleInfos)
        {
            if (axleInfo.steering)
            {
                //axleInfo.leftWheel.steerAngle = steering;
                //axleInfo.rightWheel.steerAngle = steering;
            }
            if (axleInfo.oppositeSteering)
            {
                //axleInfo.leftWheel.steerAngle = -steering;
                //axleInfo.rightWheel.steerAngle = -steering;
            }
            if (axleInfo.motor)
            {
                //axleInfo.leftWheel. motorTorque = motor;
                //axleInfo.rightWheel.motorTorque = motor;
            }
            ApplyLocalPositionToVisuals(axleInfo.leftWheel);
            ApplyLocalPositionToVisuals(axleInfo.rightWheel);
        }
    }