Quantcast
Channel: Questions in topic: "wheelcollider"
Viewing all articles
Browse latest Browse all 490

Wheel Collider Rotation

$
0
0
Hello, I am working on a car game, and have just recently gotten my car to run. However, I'm having issues with the tires rotating. My script is down below. In the last function, Update, I have attempted to make the Front Right tire rotate as the car is moving. It does, but it seemingly rotates to the Z axis as well as the X, so its like a wobbly tire. using UnityEngine; using System.Collections; using System.Collections.Generic; public class CarControllerV2 : MonoBehaviour { public WheelCollider FR; public WheelCollider FL; public WheelCollider BL; public WheelCollider BR; public Transform frontR; public Transform frontL; public Transform backR; public Transform backL; private Rigidbody rigid; public float maxTorque = 15000f; // Use this for initialization void Start () { rigid = this.GetComponent(); rigid.centerOfMass = new Vector3(0f,-0.9f,0f); } // Update is called once per frame void FixedUpdate () { BR.motorTorque = maxTorque * Input.GetAxis ("Vertical"); BL.motorTorque = maxTorque * Input.GetAxis ("Vertical"); FL.steerAngle = 200 * Input.GetAxis ("Horizontal"); FR.steerAngle = 200 * Input.GetAxis ("Horizontal"); } void Update(){ frontR.Rotate (FR.rpm / 60 * 360 * Time.deltaTime, 0, 0); } }

Viewing all articles
Browse latest Browse all 490

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>