I just wondering, if it is possible to control a mobile car game only with one thumb?
E.g. control car only with one thumb with release or without release the thumb. The simplest solution like give gas, move left or right or brake and move backwards?
It would be great if you can please add some images. This would also help others.
It’ll be very difficult. A safe way to hold a mobile with one hand is to have thumb in the middle of the screen. Meaning you won’t see much. If we’re talking about a tablet, then you’ll need to GRIP it with the thumb and won’t be able to move the thumb much.
To me it looks like a good way to make the user drop their phone.
You could control the game with one hand on a telephone that has physical keyboard, though. For example, Blackberries used to have a scrollpad(?), which was roughly in the middle of the phone, right below the screen. Meaning you finger wasn’t blocking the screen, and there was little risk of dropping the phone.
I have looked at car physic in unity, the part was for steering wheel. Something similar can be done for motor and brake torque.
this was my code (as example, I know, I have use two gui-textures for accelerate and brake for second hand. You can switch gui textures with difference calculate from touch in the TouchPhase.Began).
using UnityEngine;
using System.Collections;
public class CarController : MonoBehaviour
{
public WheelCollider[] Wheels;
public GameObject[] Disks;
public float maxMotor;
public float maxSteer;
public float brake, slowBrake;
public GameObject mass;
public GameObject SteeringWheel;
public GUITexture Gas, Brake;
float motor;
int fingerGas, fingerCtrl, fingerBrake;
bool ctrl, isBraking;
float steer, steerSpeed;
public float steerSpeedMax;
Rigidbody rb;
void Start ()
{
GetComponent <Rigidbody> ().centerOfMass = mass.transform.localPosition;
rb = GetComponent <Rigidbody> ();
}
void Update ()
{
Vector3 position;
Quaternion rotation;
for (int s = 0; s < Wheels.Length; s++) {
Wheels [s].GetWorldPose (out position, out rotation);
Disks [s].transform.position = position;
Disks [s].transform.rotation = rotation;
}
for (int i = 0; i < Input.touchCount; i++) {
Touch touch = Input.GetTouch (i);
if (touch.phase == TouchPhase.Began) {
if (Gas.HitTest (touch.position, Camera.main)) {
motor = maxMotor;
fingerGas = touch.fingerId;
} else if (Brake.HitTest (touch.position, Camera.main)) {
if (rb.velocity.sqrMagnitude > 0.1) {
motor = 0;
isBraking = true;
fingerBrake = touch.fingerId;
} else {
motor = -maxMotor;
isBraking = false;
}
} else {
ctrl = true;
steer = 0;
fingerCtrl = touch.fingerId;
}
}
if (touch.phase == TouchPhase.Moved) {
if (ctrl) {
if (touch.deltaPosition.x > 0) {
steerSpeed = steerSpeedMax * Time.deltaTime;
steer = steer + steerSpeed;
if (steer > maxSteer) {
steer = maxSteer;
}
}
if (touch.deltaPosition.x < 0) {
steerSpeed = steerSpeedMax * Time.deltaTime;
steer = steer - steerSpeed;
if (steer < -maxSteer) {
steer = -maxSteer;
}
}
}
}
if (touch.phase == TouchPhase.Ended) {
if (fingerGas == touch.fingerId) {
motor = 0;
}
if (fingerCtrl == touch.fingerId) {
ctrl = false;
steer = 0;
}
if (fingerBrake == touch.fingerId) {
motor = 0;
isBraking = false;
}
}
}
}
void FixedUpdate ()
{
if (isBraking) {
for (int a = 0; a < Wheels.Length; a++) {
Wheels [a].motorTorque = 0;
Wheels [a].brakeTorque = brake;
}
} else {
if (motor != 0) {
for (int i = 0; i < Wheels.Length; i++) {
Wheels [i].brakeTorque = 0;
Wheels [i].motorTorque = motor;
}
}
if (motor == 0) {
for (int n = 0; n < Wheels.Length; n++) {
Wheels [n].brakeTorque = slowBrake;
Wheels [n].motorTorque = 0;
}
}
}
Quaternion angle = Quaternion.Euler (0, steer, 0);
Quaternion angleWheel = Quaternion.Euler (0, 0, -steer);
SteeringWheel.transform.localRotation = angleWheel;
for (int k = 0; k < 2; k++) {
Disks [k].transform.localRotation = angle;
Wheels [k].steerAngle = steer;
}
}
}
One other possibility is to use accelerometer/gyroscope without requiring any finger movement on the screen This way people will drop phones less often
So, basically - physical buttons on the phone, accelerometer and gyroscope Anything else is a recipe for getting an upset user with a dropped phone