i am trying to work with wheel collides and i am having some problems
my real problem with is is unity or my bad knowledge with coding is not liking this part "public WheelCollider[] wheelsRight = new WheelCollider[4];" "public WheelCollider[] wheelsLeft = new WheelCollider[4];"
Here is a few errors i am getting UnityEngine.Wheelcollider[]' does not contain a definition for 'radius' and no method 'radius of type 'unityengine.WheelCollider[]' could be found. are you missing assembly reference?
the error is the same for the following Radius,rpm,brakeTorque,motorTortue. and this is all unity is telling me is wrong and my pretty beginner level of coding needs a small hand to fix this problem if anyone has an answer
using UnityEngine; using UnityEngine.UI; using System.Collections;
public class TankDrive : MonoBehaviour {
public float idealRPM = 500f;
public float maxRPM = 1000f;
public WheelCollider[] wheelsRight = new WheelCollider[4];
public WheelCollider[] wheelsLeft = new WheelCollider[4];
public float turnRadius = 6f;
public float torque = 25f;
public float brakeTorque = 100f;
public float AntiRoll = 20000.0f;
public enum DriveMode { Front, Rear, All };
public DriveMode driveMode = DriveMode.Rear;
// Use this for initialization
void Start () {
}
public float Speed() {
return wheelsLeft.radius * Mathf.PI * wheelsLeft.rpm * 60f / 1000f;
return wheelsRight.radius * Mathf.PI * wheelsRight.rpm * 60f / 1000f;
}
public float Rpm() {
return wheelsLeft.rpm;
return wheelsRight.rpm;
}
void FixedUpdate () {
float scaledTorque = Input.GetAxis ("Vertical") * torque;
if(wheelsLeft.rpm < idealRPM)
scaledTorque = Mathf.Lerp(scaledTorque/10f, scaledTorque, wheelsLeft.rpm / idealRPM );
else
scaledTorque = Mathf.Lerp(scaledTorque, 0, (wheelsLeft.rpm-idealRPM) / (maxRPM-idealRPM) );
if(wheelsRight.rpm < idealRPM)
scaledTorque = Mathf.Lerp(scaledTorque/10f, scaledTorque, wheelsRight.rpm / idealRPM );
else
scaledTorque = Mathf.Lerp(scaledTorque, 0, (wheelsRight.rpm-idealRPM) / (maxRPM-idealRPM) );
wheelsRight.brakeTorque = Input.GetAxis("Horizontal") * turnRadius;
wheelsLeft.brakeTorque = Input.GetAxis("Horizontal") * turnRadius;
wheelsRight.motorTorque = driveMode==DriveMode.Rear ? 0 : scaledTorque;
wheelsLeft.motorTorque = driveMode==DriveMode.Rear ? 0 : scaledTorque;
if(Input.GetButton("Fire1")) {
wheelsRight.brakeTorque = brakeTorque;
wheelsLeft.brakeTorque = brakeTorque;
}
else {
wheelsRight.brakeTorque = 0;
wheelsLeft.brakeTorque = 0;
}
}
}
Your answer
Follow this Question
Related Questions
Compile Error 0 Answers
How to do a wall jump? i am very novice 0 Answers
how to connect external display to second camera in unity? 0 Answers
What this error? 0 Answers
Camera Toggling Error 1 Answer