Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class controlarvei : MonoBehaviour {
- public GameObject rodad;
- public GameObject rodadp;
- public GameObject rodae;
- public GameObject rodaep;
- public GameObject rodate;
- public GameObject rodatd;
- public WheelCollider rodadireita;
- public WheelCollider rodaesquerda;
- public float maxTorque;
- public float maxAngle;
- private float actualAngle;
- private float rodada;
- // Use this for initialization
- void Start () {
- rigidbody.centerOfMass = new Vector3(0, 0, 0);
- actualAngle=maxAngle;
- }
- // Update is called once per frame
- void FixedUpdate () {
- if(rodadireita.rpm<-100) {
- actualAngle=maxAngle/((-rodadireita.rpm)/100);
- }
- rodadireita.motorTorque=maxTorque*(-Input.GetAxis("Vertical"));
- rodaesquerda.motorTorque=maxTorque*(-Input.GetAxis("Vertical"));
- rodadireita.steerAngle=actualAngle*Input.GetAxis("Horizontal");
- rodaesquerda.steerAngle=actualAngle*Input.GetAxis("Horizontal");
- rodaep.transform.localEulerAngles = new Vector3(
- rodaep.transform.localEulerAngles.x,
- rodaep.transform.localEulerAngles.y,
- actualAngle*Input.GetAxis("Horizontal")
- );
- if(rodadireita.rpm>1||rodadireita.rpm<-1) {
- rodada=rodadireita.rpm/10;
- rodad.transform.Rotate(rodada,0,0);
- rodae.transform.Rotate(rodada,0,0);
- rodatd.transform.Rotate(rodada,0,0);
- rodate.transform.Rotate(rodada,0,0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement