Регистрация | Вход
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;public class LbBrakeWheel : MonoBehaviour { public Rigidbody m_rb; public float m_curMotor = 0.0f; public float m_curTorque = 0.0f; public float m_curRpm = 0.0f; public float m_curVelocity = 0.0f; void Start () { WheelCollider wheel = gameObject.GetComponent<WheelCollider>(); wheel.motorTorque = 0; wheel.brakeTorque = 0; } void FixedUpdate() { WheelCollider wheel = gameObject.GetComponent<WheelCollider>(); m_curRpm = wheel.rpm; m_curVelocity = m_rb.velocity.z; if( Math.Abs(m_curVelocity) < 0.8f ) wheel.motorTorque += m_curVelocity; if( m_curRpm > 1 || m_curRpm < -1 ) wheel.brakeTorque = Math.Abs(wheel.motorTorque/20); else wheel.brakeTorque = 0; m_curMotor = wheel.motorTorque; m_curTorque = wheel.brakeTorque; }}
... (1) m_curVelocity = m_rb.velocity.z;... (2) wheel.motorTorque += m_curVelocity;... (3) wheel.brakeTorque = 0;...