Mouse Collision Check!!

Started by Birdron, May 20, 2014, 12:50:28 PM

Previous topic - Next topic

Birdron

Hi,
   I have to check two different collision in the game,
   1: Mouse<->plane
   2:Player<->wall

   Now, mouse is detecting both plane and wall, while I don't want the mouse to detect the wall. Player will never collide with plane, so that is not the problem.

   Is there a way to exclude the wall from mouse collision detection? The problem is, plane is below the wall. You can think the setup is "Diablo" like movement.

   Edit: Should the ellipsoid size be bigger then or equal to 1. My size is 0.5f. So, when player collides with wall, if I move the mouse left and right, it goes through the wall. My model size is: 0.1f, I had to scale it down. The movement speed is, 0.06f.

   My mouse detection method is based on the example of wiki.

   Thanks.

EgonOlsen

You can set objects to visible/invisible before the collision check. Invisible objects won't be checked.

Birdron

Ok, I could not thought about it.

And could you give me some suggestion about my second question!

Thanks.

EgonOlsen

I'm not sure what your second question exactly means. If it goes through the wall, something might be fishy with the way in which you are doing the collision detection. Or do you mean that it intersects with the wall, but doesn't pass through it?

Birdron

My movement and collision is same like the ellipsoid collision example, here it is -

   // Player movement
   SimpleVector s = player.getPlayer().getZAxis();
   s.scalarMul(SPEED);
   moveRes.add(s);

   // avoid high speeds
   if (moveRes.length() > MAXSPEED) {
      moveRes.makeEqualLength(new SimpleVector(0, 0, MAXSPEED));
   }
   // Translate player
   player.getPlayer().translate(s);
   // Check player collision
   moveRes = player.getPlayer().checkForCollisionEllipsoid(moveRes, ellipsoid, 8);
   player.getPlayer().translate(moveRes);
   // damping
   if (moveRes.length() > DAMPING) {
      moveRes.makeEqualLength(new SimpleVector(0, 0, DAMPING));
   } else {
      moveRes = new SimpleVector(0, 0, 0);
   }

EgonOlsen

Ok, but that doesn't answer my question what the actual issue is!?

Birdron

Can I pm u the runnable jar download link? I don't understand how I will explain the problem.

EgonOlsen


EgonOlsen

I see...must have something to do with the way in which moveRes is being calculated. You are using the code from the example but you modified it. Now, you are translating the player two times. One is based on the actual collision detection result but the other one is based on the player's direction without any collision detection applied to it. That can't work. As a first step, i would simply remove this line


player.getPlayer().translate(s);


Apart from that, you might want to revisit this whole thing, because i'm not sure that this kind of stuff with damping and such is needed here. The most basic approach would be something like this:


   SimpleVector s = player.getPlayer().getZAxis();
   s.scalarMul(SPEED);
   s= player.getPlayer().checkForCollisionEllipsoid(s, ellipsoid, 8);
   player.getPlayer().translate(s);



Birdron

Thank you, it is working perfectly now.