The Result of checkForCollisionEllipsoid gets me stuck.

Started by AGP, September 24, 2012, 08:23:53 PM

Previous topic - Next topic

AGP

OK, I understand your suggestion that by moving the hero by the result of calcMinDistance I accordingly affect the collision ellipsoid. But for one thing, where I'm getting stuck the terrain is plain and, for another, I can't see that as being a problem if the wall is 90 degrees to the floor (and for the most part my walls are). This problem really lies in result (or use of) checkForCollisionEllipsoid.

AGP

PS: Where I get stuck, the character is already on the ground (he doesn't fall as the one in your illustration).

EgonOlsen

It might still be caused by some inaccuracies between the two methods. Try to make the radius of the ellipsoid in y-direction a little lower than the actual distance from the ground so that the ellipsoid doesn't touch it. If that doesn't help, continue to play around with the parameters. There's no reason why it should get stuck on a plain, but it might if (for example) the threshold is very small. I would avoid combining the two methods anyway.

AGP

For whatever it's worth I added the following code to collide. If it collidedThisFrame, I don't move with calcMinDistance(). As I expected, it did not solve my problem, but at least now we know what the trouble is.


if (directionToHead.x != direction.x || directionToHead.z != direction.z)
     collidedThisFrame = true;
else collidedThisFrame = false;

AGP

I tried collideOffset, gradually increasing it all the way to 1000. It didn't help.

EgonOlsen

Just stop using calcMinDistance at all. Try to use ellipsoid detection only.

AGP

How would this particular problem be helped by that? Especially since I don't use it after checkForEllipsoidCollision returns a SimpleVector other than the one it's passed.

EgonOlsen

It cleans up things to make it easier to track down the actual issue. I've no real idea what you are doing right now. The ellipsoid you are using is very small. I've no idea if that actually matches your geometry or not. Then there's some if-clause which decides if calcMinDistance will be used or not where you actually shouldn't use it anyway in this case (as explained in my drawing)...it all seems pretty convoluted to me and that makes it hard to find the real problem here. So i suggest to:


  • Use an ellipsoid that has the size of the hero.
  • Make sure that it covers the hero more or less.
  • Leave out any gravity related code. You don't need it in this test case anyway (judging from the video).
  • Make that work, then add additional stuff. Don't add additional stuff to something that is already broken. Take one or two steps back instead.

Your final collision method should have a few lines only. Do an ellipsoid collision detection for the hero, move the hero according to the results. That's all. No gravity, no ifs, nothing else. To make this work has to be first priority.

AGP

Then I propose either (the more likely knowing you) a method like checkForCollisionEllipsoid that automatically gets the size of the Object3D or (less likely knowing what you'll say about the pipeline) a drawEllipsoid(same arguments as checkForColEllipsoid). Otherwise it's too much guesswork, man.

EgonOlsen

I see your point, but that won't help much IMHO. It might be useful for the y-dimension of an object, but for normal collision detection, you want to extend the ellipsoid into x- and z-direction to some degree. You usually don't want to use a tight fitting ellipsoid. Apart from that, it's not a trivial problem and actually unsolvable in a lot of cases. In your case, you won't use an ellipsoid that covers both feet of your hero, because that would extend into the ground.
Use Mesh.getBoundingBox() for now, subtract the min from the max values, divide them by 2 and you have your basic values for the ellipsoid's radius. Add something to x and z just to be sure. Place it above the ground, so that it's close to it but doesn't intersect.

AGP

Covering the feet won't be a big priority (it doesn't have to look absolutely perfect, it just has to work). I'll try your values and report back, thanks.