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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Help with the rigidbody, colliders, triggers, etc

Discussion in 'Editor & General Support' started by svprdga, Aug 23, 2012.

  1. svprdga

    svprdga

    Joined:
    Aug 21, 2012
    Posts:
    14
    I'm getting really crazy with this rigidbody, collider, and triggers story...

    I just want to make a simple pong game, so it will be three elements: the paddles, the upper and lower limits, and the ball. I try so many configurations but always there is something that goes wrong.

    If I make the limits with a simple non trigger collider, the paddles with a rigidbody and then the ball rigidbody too; the paddles get stuck when the ball collides...and so other problems with collisions If I try another configurations.

    Any ideas?

    Thanks.
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Can you give any more detail about how/where the paddles are getting stuck and maybe post the code you are using?
     
  3. svprdga

    svprdga

    Joined:
    Aug 21, 2012
    Posts:
    14
    Hey, I found by myself the solution:

    I set the upper and lower limit with a simple collider; and the paddles and the ball with simple rigidbodies. I discovered the axis constraint; so I let the paddles only to move in the Y axis (up down), now their trajectory are not affected by the ball blow.

    :)
     
  4. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    For anything that requires precise angles and such simple collision I would consider writing my own collision system. I don't think you will get a satisfactory result with PhysX, but I could be mistaken.

    For something like pong I guess you just limit the paddles between 0 - screen height vertically and the ball you can just use a bounding box and when this box overlaps either the top or bottom or any of the paddles you just send the ball along the reflected angle.

    Another thing with pong is that you should be able to control the reflected angle depending on where on the paddle it hits, this I don't think will be easy to achieve with PhysX, but trivial if you create your own system.
     
  5. svprdga

    svprdga

    Joined:
    Aug 21, 2012
    Posts:
    14
    I'm trying to do my best to use the PhysX engine, I just did a post asking for a bounce ball effect. About the reflected angle depending on where the ball hit the paddles; if I get the ball bounce effect; I will curve the paddles surface, so the ball will get this "pong angle" effect.

    But; if I not achieve to do that with PhysX, I will not have any other choice than create my own physic system.
     
  6. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Heh, a curved paddle could actually be cool. Let me know how it works out for you. :)