- Home /
Why won't my car steer?
Hello guys! I can't make my car steer. On the computer it runs ok with those Input.GetAxis, but I can't make it work on the android device. What should I change in this code to make it run on phone? Also what is a substitute for Input.GetAxis for android, because it doesn't seem to be working on phone. Thanks in advance!
var maxTorque : float = 200;
var speed:float=3;
var GasTouch : int = 0;
var Steer : int = 0;
var BackLeft : WheelCollider;
var BackRight : WheelCollider;
var FrontLeft : WheelCollider;
var FrontRight : WheelCollider;
var LeftButton : GUITexture;
var RightButton : GUITexture;
var GasButton : GUITexture;
var Joystick : GUITexture;
function Awake()
{ Joystick = GameObject.Find("Joystick").guiTexture;
LeftButton = GameObject.Find("LeftButton").guiTexture;
RightButton = GameObject.Find("RightButton").guiTexture;
GasButton = GameObject.Find("GasButton").guiTexture;
}
function Update()
{
BackLeft.motorTorque=-maxTorque * Input.GetAxis("Vertical");
BackRight.motorTorque=maxTorque * Input.GetAxis("Vertical");
//FrontLeft.steerAngle=20 * Input.GetAxis("Horizontal");
// FrontRight.steerAngle=20 * Input.GetAxis("Horizontal");
for (var touch : Touch in Input.touches)
{
if (touch.phase == TouchPhase.Stationary && GasButton.HitTest (touch.position)) {
GasTouch = 1;
}
else if (touch.phase == TouchPhase.Ended && GasButton.HitTest) {
GasTouch = 0;
}
if (touch.phase == TouchPhase.Stationary && LeftButton.HitTest (touch.position)) {
Steer = -1;
FrontLeft.steerAngle = -15.0;
FrontRight.steerAngle = -15.0;
}
else if (touch.phase == TouchPhase.Ended && LeftButton.HitTest){
Steer = 0;
FrontLeft.steerAngle = 0;
FrontRight.steerAngle = 0;
}
if (touch.phase == TouchPhase.Stationary && RightButton.HitTest (touch.position)) {
Steer = 1;
FrontLeft.steerAngle = 15.0;
FrontRight.steerAngle = 15.0;
}
else if (touch.phase == TouchPhase.Ended && RightButton.HitTest){
Steer = 0;
FrontLeft.steerAngle = 0;
FrontRight.steerAngle = 0;
}
}
if(GasTouch!=0)
{
transform.Translate(Vector3.forward*speed/100);
}
Come on guys, I'm a beginner and I've been stuck on this for two days now.
Answer by Benproductions1 · Sep 10, 2013 at 11:45 PM
Hello,
This one link will answer all your questions:
http://lmgtfy.com?q=Unity+Android+Input
Hope this helps,
Benproductions1
Yea, well, thank you. $$anonymous$$y native language isn't English so thank you for looking that up for me. I realize now that my question was kind of stupid...
Glad I could help, I hope next time your question won't be answerable by a google link ;)
Your answer
Follow this Question
Related Questions
How to make car AI using WheelColliders turn exactly 90 degrees? 0 Answers
Wheelcolliders launch the car. 0 Answers
Perfect friction with WheelColliders 1 Answer
How to make a car not slow down while turning? 2 Answers
Car wheel not detecting ground 1 Answer