Hi there,
I’m trying to get the Android/iOS controls up and running for my racing game, now that the desktop version is complete… I’m having issues with the multi-touch. For some reason, when I try steering, it stops accelerating until I release the steering button again. Probably something simple, I’m new to this touch stuff… any ideas?
EDIT: New code - multi-touch working but buggy - bools stay activated etc, so car tends to all of a sudden veer off the road or stop accelerating.
function OnGUI()
{
for (var i = 0; i < Input.touchCount; ++i)
{
if (Input.GetTouch(i).phase != TouchPhase.Ended && Input.GetTouch(i).phase != TouchPhase.Canceled)
{
if (GasButton.HitTest(Input.GetTouch(i).position))
{
bGasButtonPressed = true;
}
if (TurnLeft.HitTest(Input.GetTouch(i).position))
{
bLeftButtonPressed = true;
}
if (TurnRight.HitTest(Input.GetTouch(i).position))
{
bRightButtonPressed = true;
}
}
else
{
bGasButtonPressed = false;
bLeftButtonPressed = false;
bRightButtonPressed = false;
}
}
}