var WheelFR : UnityEngine.WheelCollider;
var WheelFL : UnityEngine.WheelCollider;
var WheelRR : UnityEngine.WheelCollider;
var WheelRL : UnityEngine.WheelCollider;
var speed = 10;
var braking = 20;
var turning = 20;
function update ()
{
//this code makes the car go forward
wheelRR.motortorque = Input.GetAxis(“vertical”) * speed;
wheelRL.motortorque = Input.GetAxis(“vertical”) * speed;
wheelRL.motortorque = 0;
wheelRR.motortorque = 0;
//this code makes the car turn
wheelFL.steerangle = Input.GetAxis(“horizontal”) * turning;
wheelFR.steerangle = Input.GetAxis(“horizontal”) * turning;
//this code puts brakes on the car
if ( input.getkey(KeyCode.spacebar))
{
wheelRL.braketorque = braking;
wheelRR.braketorque = braking;
}
}
can anyone help me out with this? i followed a youtube video and he didnt run into these issues, but then again he only put .wheelcollider when unity told me to do unityengine.wheelcollider… so i think maby he was on 3.5… idk
sorry update on my part i see the issue, the W needed to be capitol for Wheel and Input, now i added the script to a basic cube with 4 wheel colliders and the wheel colliders are assigned in the script part of the inspector, but when i try and move the car wont move, and im getting no compile errors?
//this code puts brakes on the car
if ( UnityEngine.Input.GetKey(KeyCode.Spacebar))
it needed to be:
//this code puts brakes on the car
if ( UnityEngine.Input.GetKey(KeyCode.Space))
now im not getting any errors but the box i made with wheel colliders still isnt moving, i gave the wheel colliders targets when i dragged the script into the box as well.
how do you post code the correct way? anyways here is what i have, and the car still wont move… but i dont have any console errors.
var WheelFR : UnityEngine.WheelCollider;
var WheelFL : UnityEngine.WheelCollider;
var WheelRR : UnityEngine.WheelCollider;
var WheelRL : UnityEngine.WheelCollider;
var speed = 10;
var braking = 20;
var turning = 20;
function Update ()
{
//this code makes the car go forward
WheelRR.motorTorque = Input.GetAxis(“Vertical”) * speed;
WheelRL.motorTorque = Input.GetAxis(“Vertical”) * speed;
WheelRL.motorTorque = 0;
WheelRR.motorTorque = 0;
//this code makes the car turn
WheelFL.steerAngle = Input.GetAxis(“Horizontal”) * turning;
WheelFR.steerAngle = Input.GetAxis(“Horizontal”) * turning;
//this code puts brakes on the car
if ( UnityEngine.Input.GetKey(KeyCode.Space))
{
WheelRL.brakeTorque = braking;
WheelRR.brakeTorque = braking;
}
}
if i set them to anything but zero the car moves by itself, and all i can do i brake. im starting to think its something else instead of the code at this point. does any one mind pluggin this code into a cube with wheel colliders and see if they can find out whats wrong?
var WheelFR : UnityEngine.WheelCollider;
var WheelFL : UnityEngine.WheelCollider;
var WheelRR : UnityEngine.WheelCollider;
var WheelRL : UnityEngine.WheelCollider;
var speed = 10;
var braking = 20;
var turning = 20;
function Update ()
{
//this code makes the car go forward
WheelRR.motorTorque = Input.GetAxis("Vertical") * speed;
WheelRL.motorTorque = Input.GetAxis("Vertical") * speed;
WheelRL.motorTorque = 0;
WheelRR.motorTorque = 0;
//this code makes the car turn
WheelFL.steerAngle = Input.GetAxis("Horizontal") * turning;
WheelFR.steerAngle = Input.GetAxis("Horizontal") * turning;
//this code puts brakes on the car
if ( UnityEngine.Input.GetKey(KeyCode.Space))
{
WheelRL.brakeTorque = braking;
WheelRR.brakeTorque = braking;
}
}
I’d check your Input Manager and see what the Vertical and Horizontal axes are bound to. It sounds like you’re picking up input when you don’t want to.
var WheelFR : UnityEngine.WheelCollider;
var WheelFL : UnityEngine.WheelCollider;
var WheelRR : UnityEngine.WheelCollider;
var WheelRL : UnityEngine.WheelCollider;
var speed = 10;
var braking = 20;
var turning = 20;
function Update ()
{
//this code makes the car go forward
WheelRR.motorTorque = Input.GetAxis("Vertical") * speed;
WheelRL.motorTorque = Input.GetAxis("Vertical") * speed;
//this code makes the car turn
WheelFL.steerAngle = Input.GetAxis("Horizontal") * turning;
WheelFR.steerAngle = Input.GetAxis("Horizontal") * turning;
//this code puts brakes on the car
if ( UnityEngine.Input.GetKey(KeyCode.Space))
{
WheelRL.brakeTorque = braking;
WheelRR.brakeTorque = braking;
}
else
{
WheelRL.brakeTorque = 0;
WheelRR.brakeTorque = 0;
}
}