Search Unity

Crown Green Bowling Ball problem when bowling with HTC Vive Controller

Discussion in 'AR/VR (XR) Discussion' started by knighthawk, Sep 23, 2016.

  1. knighthawk

    knighthawk

    Joined:
    Nov 30, 2014
    Posts:
    34
    Hi,

    I have the starts of a Crown Green bowling game and using VIVE with SteamVR and VRTK.

    The problem I am coming across is trying to get a smooth departure from the controller to a nice rolling bowl that comes to a nice stop.

    I have tried a few different ways, Pure physics simulation, with adding the velocity of the controller to the Rigidbody.

    I have tried hundreds of different Physics materials and different masses and Drags.

    I have also tried playing with adding my own torque to see if I could get anything like, but still struggling.

    The problem I am getting is when I release the ball, which sure enough does push forward with the velocity of the controller, is that as soon as it touches the floor it's like it is hitting a puddle or sticky floor.

    If I turn the friction down to compensate it just slides unrealistically.

    I have tried, Parenting, Joints, and simply move to position of the VIVE controller.

    Anybody come across similar, I have a croquet game which works fine but then I am hitting the ball with a mallet, and if I apply torque forces to the Bowl then it rolls fine.

    I will post some links to videos as soon as I have done them.

    Code (CSharp):
    1. void OnTriggerStay(Collider col)
    2.     {
    3.         //Logger.Log("You have collided with " + col.name + " and activated OnTriggerStay");
    4.         if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
    5.         {
    6.             //Logger.Log("You have collided with " + col.name + " while holding down touch");
    7.             col.attachedRigidbody.isKinematic = true;
    8.             col.gameObject.transform.SetParent(this.gameObject.transform);
    9.         }
    10.  
    11.         if(device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
    12.         {
    13.             //Logger.Log("You have released touch while colliding with " + col.name);
    14.             col.gameObject.transform.SetParent(null);
    15.             col.attachedRigidbody.isKinematic = false;
    16.  
    17.             tossObject(col.attachedRigidbody);
    18.         }
    19.     }
    20.  
    21.     void tossObject(Rigidbody rigidbody)
    22.     {
    23.         Transform origin = trackedObj.origin ? trackedObj.origin : trackedObj.transform.parent;
    24.         if(origin != null)
    25.         {
    26.  
    27.             Logger.Log("Velocity of the controller = " + device.velocity.magnitude);
    28.             Logger.Log("Angular Velocity of the controller = " + device.angularVelocity.magnitude);
    29.             //rigidbody.AddTorque(new Vector3(0,0,-1000.0f),ForceMode.Impulse);
    30.             rigidbody.velocity = origin.TransformVector(device.velocity);
    31.             rigidbody.angularVelocity = origin.TransformVector(device.angularVelocity * 1000);
    32.         }
    33.         else
    34.         {
    35.             rigidbody.velocity = device.velocity;
    36.             rigidbody.angularVelocity = device.angularVelocity;
    37.         }
    38.     }
    Thanks

    Mike
     
  2. knighthawk

    knighthawk

    Joined:
    Nov 30, 2014
    Posts:
    34
    Hi,

    Video link below.

    As you can see, whether close to the floor or throwing it, it seems to come to an abrupt slow down.

    I have also tried increasing Mass to large values and also increasing the scale.



    Mike
     
    Last edited: Sep 23, 2016
  3. knighthawk

    knighthawk

    Joined:
    Nov 30, 2014
    Posts:
    34
    I have managed to improve it drastically, but I have had to scale the bowl up to nearly as tall as me.

    So I think I will have a look at a custom physics model for the bowl and see what I can do.

    Mike
     
  4. knighthawk

    knighthawk

    Joined:
    Nov 30, 2014
    Posts:
    34
    All sorted,

    I had to use maxAngularVelocity, works a treat.

    Mike