Search Unity

Suggestions for physics on hand tracked objects in a table tennis game

Discussion in 'Physics' started by MarkSchramm, Sep 15, 2015.

  1. MarkSchramm

    MarkSchramm

    Joined:
    Nov 5, 2013
    Posts:
    8
    Hi physics people,

    I'm not that good with the physics system. I want to make a table tennis game with hand tracked input like the playstation move controllers of razer hydra and I need some help getting the physics right.
    Here's what I've done so far:

    - cranked up the fixedupdate timestep to 0.01
    - different physics material on bat, table and ball
    - Moved the controllers with RIgidbody.moveposition and moverotation

    I've detected 2 problems so far:
    - Even with higher timesteps, the ball still goes through the bat
    - The bat does not do some kind of "hit force" do I have to make this myself in the OnColliderEnter? I thought the "bounce" variable of the material is handling that

    Help or some good settings for rigidbodys and materials would be much appreciated!
     
  2. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    Try setting the rigidbodys collision detection to continuous dynamic in the inspector.
    Also, you might need to use AddForce / AddTorque instead of moveposition and moverotation. Not sure though.

    Also make sure you are doing all of this in fixedupdate and not update.
     
  3. Pararea

    Pararea

    Joined:
    Aug 31, 2017
    Posts:
    2
    any suggestion?
     
  4. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Don't increase the timestep. Instead you want to use Continuous Dynamic collision detection on your rigidbodies.

    Do not use MovePosition if you intend to collide with other objects.
    From the scripting API documentation, at the bottom:
    which consequently avoids any sort of collision.

    You will instead want to change the rigidbody's velocity. A PID controller is quite handy for this.