Search Unity

Help with pool table physics

Discussion in 'Physics' started by JeremyToler, Aug 22, 2019.

  1. JeremyToler

    JeremyToler

    Joined:
    Jul 11, 2015
    Posts:
    20
    When you hit a ball that is pressed up against the edge of a pool table it will move away from the wall. When using the standard unity physics with rigidbody2D it does not (see gif).

    https://imgur.com/a/WpiNzCr

    What is the best way to fix this? I thought about writing a script that detected collisions and attaching it to the walls but I think that's not going to work (OnCollisionEnter would trigger when the ball hit the wall, not when it is hit by the cue ball against a wall and onOnCollisionExit would not trigger in this instance).

    I'm lost here, if you can point me in the right direction it would help a lot, thanks.
     
  2. vagelis199

    vagelis199

    Joined:
    Jul 27, 2012
    Posts:
    36
    Maybe add some bunciness to the walls by adding a custom collision material
     
  3. JeremyToler

    JeremyToler

    Joined:
    Jul 11, 2015
    Posts:
    20
    I have a material with bounciness set to 1 on the walls already.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    1,972
    JeremyToler likes this.
  5. JeremyToler

    JeremyToler

    Joined:
    Jul 11, 2015
    Posts:
    20
    Thank you, this is what I needed. with a bit of finagling I got it to work the way I wanted with a velocity threshold of 0.08
     
    MelvMay likes this.