Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Racing game controller

Discussion in 'Game Design' started by Voldana78, Mar 18, 2022.

  1. Voldana78


    Jun 12, 2021
    Hi there, I've been recently trying to make a racing/drifting game for phones everything worked fine, The mechanics the environment and all the other stuff, however I feel my control mechanic is a bit off.
    I'm using a Swipe controller for my game so it can be played with one hand ( I noticed this is what alot of mobile game developers do), I'm using this piece of code to get the horizontal input from the user:

    Code (CSharp):
    1.             if (Input.touchCount > 0)
    2.             {
    3.                 Touch touch = Input.touches[0];
    4.                 switch (touch.phase)
    5.                 {
    6.                     case TouchPhase.Began:
    7.                         IsHold = true;
    8.                         startPosition = touch.position;
    9.                         break;
    10.                     case TouchPhase.Moved:
    11.                         var distance = (touch.position.x - startPosition.x) * factor;
    12.                         Horizontal = Mathf.Clamp(distance, -1f, 1f);
    13.                         break;
    14.                     case TouchPhase.Ended:
    15.                         IsHold = false;
    16.                         Horizontal = 0;
    17.                         break;
    18.                 }
    19.             }
    I then modify the horizontal value with a curve so the control sensitivity differ when the user swipes a little or a lot, I've used both the simple curves like x^2 or x^ (1/2) and also more complicated ones but none of them gives me the right feeling, there are a lot of objects in the road that you have to dodge and the turns in the road are mostly 90 degree turns so I need something that user feels comfortable with, I've also tried linear values like y=x but that didn't work either.
    I've asked alot of people to test my game but whenever I feel like I've reached something they all go like nah it's too sensitive and hard so i decided to ask the community
    If you guys can help in any way it'd be a huge help like what kind of formula or animation curve do i need to use for a better user experience.