Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Ball hitting wall physics

Discussion in 'Physics' started by Karwoch, Jan 6, 2015.

  1. Karwoch

    Karwoch

    Joined:
    Sep 16, 2014
    Posts:
    110
    There is a lot about that topic but nowhere an answer. I`m trying to do pretty easy task - mini golf. Have flat ground, have walls, I move ball with addforce function. But when it comes to hit walls, it bounces totally randomly, sometimes even it get back when it hit wall at 45 angle! I read that some people write their own bounce function, but it is a little bit insane when phisycs engine just should do something as simple as wall bounce.

    I tried very much different configuration, with angular velocity, without, with bouncines, and without, different friction, on ball and on wall, all configuration with wall physics and without. It seems like Unity physics in contatct with walls have their own life and idea about physics ;)

    Any help, or idea? It... really should be a very simple matter.
     
  2. Uberpete

    Uberpete

    Joined:
    Jan 16, 2014
    Posts:
    78
    Create a trigger on the walls that reduces the velocity of the balls when they enter?
     
  3. Karwoch

    Karwoch

    Joined:
    Sep 16, 2014
    Posts:
    110
    I have found what is the problem. My walls where build from cubes with box colliders, and Unity have greate problem with that.My box colliders where perfectly matched, but still Unity physics engine read collider hit as one object, so You can hit box corner and ball will bounce of corner, even if there is another collider - it is as if You would hit a brick wall, and ball would bounce off ones brick corner - even if there is no corner on wall.

    It becomes obvious it is engine problem when box colliders are strecht to each other, and they still act as if they have corners. If anybody knows any way around, I reall would appricieate it! As doing separate collider physcis for every object I will create is ridiculus, especially if You have should-work engine...