Search Unity

Problem with Ball Controll on Android

Discussion in 'Physics' started by Dawid_Matuszewski, May 2, 2019.

  1. Dawid_Matuszewski

    Dawid_Matuszewski

    Joined:
    Mar 2, 2016
    Posts:
    23
    Hi, I have a problem with my mobile game in which I'm controlling a ball using accelerometer. I'm using "AddForce" on a Rigidbody, but the ball isn't responsive enough. So if I want to stop my ball quickly, the delay is too long. Same solution on PC (using GetAxisRow-Horizontal/Vertical) is working quite well. I tried to use Rigidbody.velocity and I managed to eliminate the delay, but then the rest of game phisics isn't behaving correctly.
    Is there a mobile counterpart for "GetAxisRaw"?
    I'm using Unity 2018.3.12f1.
    I will appreciate any help, thank you :)
     

    Attached Files:

    Last edited: May 2, 2019
  2. SamuelAsherRivello

    SamuelAsherRivello

    Joined:
    Jan 16, 2011
    Posts:
    42
    Good question.

    If you look at this demo project

    https://unity3d.com/es/learn/tutorials/s/roll-ball-tutorial

    You'll see that it uses input multiplied by a constant (e.g. a speed float with value of 5) for the AddForce()

    The higher speed makes your controls more responsive.

    If you want the object to 'slow down' more quickly you can increase its RigidBody.mass. Or you can apply a PhyisicsMaterial with friction to the moving object or the floor object.

    Try that!