Author Topic: Collision Trouble  (Read 2918 times)

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Collision Trouble
« Reply #15 on: June 28, 2014, 09:32:15 am »
Here's the problem I'm having with the collision-detection against the ball only working the first couple of times. As the video shows, even when the collision against the ball stops working, the collision against the other players works.

https://dl.dropboxusercontent.com/u/93826015/java%202014-06-28%2004-23-58-66_x264.mp4

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision Trouble
« Reply #16 on: June 28, 2014, 09:31:58 pm »
What exactly are you using for player-ball collisions?

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Collision Trouble
« Reply #17 on: June 29, 2014, 04:54:06 am »
This:

Code: [Select]
SimpleVector direction = collideWithBallEllipsoid(new SimpleVector(selectedPlayer.getRoot().getZAxis().x*-.5f, selectedPlayer.getRoot().getZAxis().y*-.5f, selectedPlayer.getRoot().getZAxis().z*-.5f));
ball.direction.add(direction);

Code: [Select]
     private SimpleVector collideWithBallEllipsoid(SimpleVector playerDirection) {
SimpleVector direction = selectedPlayer.get(0).checkForCollisionEllipsoid(playerDirection, new SimpleVector(1f, 4f, 1f), 3);
if (direction.equals(playerDirection))
     return SimpleVector.ORIGIN;
else if (!direction.equals(playerDirection) && !ball.ball.wasTargetOfLastCollision()) {
     selectedPlayer.collided = true;
     return SimpleVector.ORIGIN;
}
direction.y = 0.00f;
return direction;
     }

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision Trouble
« Reply #18 on: June 30, 2014, 01:40:44 pm »
So the ball gets the correctly player direction assigned to it? If that's the case, what happens to the player then? Ellipsoid collision detection is a collision avoidance algorithm. It can't handle the case that a collision is present already when you call the method. So if it can happen that the player already insects the ball before the call, the results won't be great. To be honest, i wouldn't use this kind of collision detection at all for this kind of problem but some heuristic method based on positions and movement instead.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Collision Trouble
« Reply #19 on: June 30, 2014, 10:57:26 pm »
OK, thanks, but first things first: isn't it a bug that after a couple of successful collisions the collisions stop working altogether?

When would you use actual collisions? And which type of collision-detection would you prefer?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision Trouble
« Reply #20 on: July 01, 2014, 12:00:53 am »
No, i don't think it's a bug. As mentioned, the idea is to correct the translation vector of the colliding object in a way that the collision doesn't happen and the method is actually really stable in providing this. You actually don't use it that way but you apply the translation to the obstacle instead to move it out of the way if i got that right. I think that this might cause the problems that you see, albeit i'm not entirely sure what's going on exactly. It might be the case that the player would actually climb onto the ball but because you apply the translation to the ball instead but without the y component of the translation, the player might move into the ball...or something similar.
However, ellipsoid collision detection is the most tested method in the whole engine and you can be pretty sure that it works the way it's intended to. I know that this sounds stupid, but if it doesn't work then you are either doing it wrong or you are using it in a way in which it's not meant to be used.
About the alternatives...i'm not sure...i would try something based on ball and player position, player direction and radius.
« Last Edit: July 01, 2014, 07:48:35 am by EgonOlsen »

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Collision Trouble
« Reply #21 on: July 03, 2014, 01:51:23 am »
Egon, I'm in dire need of that World.getScaleInWorldspaceUnits() (or so) method about which we talked. Would you be so kind as to implement it before your next release?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision Trouble
« Reply #22 on: July 03, 2014, 07:35:06 am »
I'll look into it.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision Trouble
« Reply #23 on: July 03, 2014, 05:12:08 pm »
Please give this jar a try: http://jpct.de/download/beta/jpct.jar

it adds a getBounds() method to World. The parameter allows you to limit the calculation to visible objects only (true) or all (false).

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Collision Trouble
« Reply #24 on: July 04, 2014, 08:03:21 am »
Awesome. Thanks a lot, pal.

Offline AGP

  • quad
  • ******
  • Posts: 1526
    • View Profile
Re: Collision Trouble
« Reply #25 on: July 04, 2014, 08:14:42 am »
The first thing that I noticed is that the jar is 5 KB smaller than the previous latest version. And is it possible that it got a little slower?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Collision Trouble
« Reply #26 on: July 04, 2014, 09:57:50 am »
No idea why it's smaller. Might be that i built it in another way the last time. It shouldn't be slower. Performance sometimes slightly changes between versions because of different memory alignment of the code and stuff like that. There's nothing you can do about that.