Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created May 21, 2018 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/14f70dd593788602437a8c1131f8a18e to your computer and use it in GitHub Desktop.
Save todorok1/14f70dd593788602437a8c1131f8a18e to your computer and use it in GitHub Desktop.
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