Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
UnityのWheel Colliderのチュートリアルをバイクで
public void FixedUpdate(){
float motor = maxMotorTorque * Input.GetAxis("Vertical");
float steering = maxSteeringAngle * Input.GetAxis("Horizontal");
foreach (AxleInfo axleInfo in axleInfos) {
if (axleInfo.leftWheel != null){
if (axleInfo.steering) {
axleInfo.leftWheel.steerAngle = steering;
}
if (axleInfo.motor) {
axleInfo.leftWheel.motorTorque = motor;
}
ApplyLocalPositionToVisuals(axleInfo.leftWheel);
}
if (axleInfo.rightWheel != null){
if (axleInfo.steering) {
axleInfo.rightWheel.steerAngle = steering;
}
if (axleInfo.motor) {
axleInfo.rightWheel.motorTorque = motor;
}
ApplyLocalPositionToVisuals(axleInfo.rightWheel);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.