Collision not working

Started by fireside, February 20, 2008, 06:13:02 AM

Previous topic - Next topic

fireside

I tried doing a search for collision and came up with this function for the mouse:
private void doGravity()
{
      SimpleVector msPos=Mouse.getTransformedCenter();
      msPos.add(msHgt);
      if(world.checkCollision(msPos, dr, .6f)== Object3D.NO_OBJECT)
      {
    Mouse.translate(gravity); 
      }           
}
private void move()
{
SimpleVector a = Mouse.getZAxis();
a.scalarMul(-.15f);
a = Mouse.checkForCollisionEllipsoid(a, elipse, 2);
Mouse.translate(a);
}


The gravity part works, but the mouse walks through as in this picture:


The elipse is (2,5,2)  The five is the mouse height and works for gravity.

The platform is set for collision with this code:
    platform.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
    platform.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);


I tried setting collision for the mouse but it didn't help.  I had to use -.15 in the scalermult or else the mouse went backwards.
click here->Fireside 7 Games<-

EgonOlsen

Does the mouse starts in that location or is he in front of that block in the beginning?

fireside

He's in front of the block and walks right through it.
click here->Fireside 7 Games<-

EgonOlsen

How much in front? Make sure that the ellipsoid doesn't intersect with the block at the beginning, because the ellipsoid collision detection is a collision avoidance algorithm. It can't resolve an existing collision.

fireside

#4
Way in front.  He starts at the middle of the platform.  And I can walk him all the way to the other side, turn around, and he goes through.  I know the block is doing collision.  It's combined, but I can drop the mouse from high up and it will stop on top the block if I move him over to where the block is when the program starts, so the move function isn't working for some reason.
click here->Fireside 7 Games<-

EgonOlsen

And the mouse is set to COLLISION_CHECK_SELF?

fireside

Ha, you beat me to it.  I just tried that.  That's what it was.
click here->Fireside 7 Games<-