- Home /
Question by
Npkhan · Jul 20, 2017 at 03:19 PM ·
uimobileevent triggeringinput.getaxiscar game
How can I Take axis and turn wheel using pointer event from UI button for mobile platform..?
Hello there I am very new in scripting and i am trying to take axis using UI button and make CAR forward/backward and turn wheel left and right using two UI button.I want to build the game for mobile. I tried pointer event but it showed errors. I am giving code which i got from net. Can anybody please please write the pointer event code for me.I am trying it since 1 month.
public void FixedUpdate()
{
//Turn the wheels to a set max, with an input.
float steer = Input.GetAxis("Horizontal") * maxSteerAngle;
//Move forward or backwards based on the maxSpeed, with an input.
float torque = Input.GetAxis("Vertical") * maxSpeed;
//Sets which wheels turn, this is the two front wheels.
wheelCollider[0].steerAngle = steer;
wheelCollider[1].steerAngle = steer;
//Sets which wheels move forward or backwards.
for (int i = 0; i < 4; i++)
{
wheelCollider[i].motorTorque = torque;
}
}
Comment
Your answer
Follow this Question
Related Questions
EventSystem.current.IsPointerOverGameObject Issues with Mobile 0 Answers
CrossPlatformMobileInput Joystick.cs not working 0 Answers
Child UI is backfiring 0 Answers
Pressing two buttons simultaneously with the same touch 2 Answers
Button issues since Catalina 0 Answers