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. Dismiss Notice

Question Question on how to improve my little physic ball game

Discussion in 'Physics' started by ABB13, Jul 21, 2023.

  1. ABB13

    ABB13

    Joined:
    Apr 23, 2018
    Posts:
    67
    I'm creating a small game for my AR application, where I control a ball by tilting the plane I'm holding in my hand.

    I've added a Rigidbody component to the sphere, and while it works, controlling the ball is proving to be too difficult. Is there a way I can improve its responsiveness? Do I need to create a custom script for this?

    I've attempted to adjust the Rigidbody settings, but unfortunately, I haven't had much success.

    Could anyone help me out?
     
  2. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Rigidbody mass and angularDrag would be the relevant physics settings. Also you could increase gravity to just make it fall harder downwards. The collider/rigidbody surface material, and your plane collider material, affect bounciness and friction, if you want those.
     
    ABB13 likes this.
  3. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    510
    You may be able to improve responsiveness by increasing the physics frame rate.

    Project Settings/Time/Fixed Timestep

    Change it to 0.01666 for 60 frames per second.
     
    ABB13 likes this.
  4. ABB13

    ABB13

    Joined:
    Apr 23, 2018
    Posts:
    67
    First of all thank you for your help, and I want to ask you: what type of surface material can affect friction?


    Thanks I will try it :D
     
  5. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    They are called Physic Materials, if you look at any 3D collider you'll see this field. It's not the same as a rendering material although the field name is the same. You can create new Physic Materials yourself from the Create menu.
     
    ABB13 likes this.
  6. ABB13

    ABB13

    Joined:
    Apr 23, 2018
    Posts:
    67
    Thank you :), I will try it out
     
  7. ABB13

    ABB13

    Joined:
    Apr 23, 2018
    Posts:
    67
    I'm trying to change the parameters that you told me about here, but it doesn't seem to influence the ball at all. For this reason, I want to ask you if the size of the ball could influence the rigidbody, because the ball's size is set to 0.006 and the collider size is set to 0.5.

    upload_2023-8-1_9-21-12.png
     
  8. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    I think your scales are too small which can cause physics issues. Physics is tuned to work with reasonable scales and it's better if mass and scale are closer to 1. If your ball represents a real life marble, then maybe think of units like 1 = 1 cm, and scale all your objects with this basic unit.
     
  9. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    510
    If you're using AR Foundation then the tracking can be a little iffy, especially if you're looking down at the ground and there's not many trackable features down there. If you just need a virtual ball to roll around on the screen then you could look into bypassing AR Foundation and using the gyroscope for tracking and enable the camera yourself.
     
  10. zulo3d

    zulo3d

    Joined:
    Feb 18, 2023
    Posts:
    510
    Oh wait... I just realized that you may be using image tracking to control the plane that the ball rolls around upon. I once had a play around with image tracking and I found it to be very unreliable. So you may be asking a little too much to be able to control the ball reliably..

    You may be able to add a rigidbody to a plane that tracks the image marker that tracks your hand and this should give smoother results but then you'll probably have lots of latency.