Author Topic: How does colision detection work on player?  (Read 1217 times)

0 Members and 1 Guest are viewing this topic.

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
How does colision detection work on player?
I've recently noticed a strange thing when testing landings with a flat and long fighter. When I "hit the deck", the bottom side of my fighter was still above the surface of the fighterbay, but when I turned around, nothing prevented me from doing a full turn, allowing me to stick my nose throught the runway. This made me wonder how colision detection is calculated on player's ship, since it seemed to use some kind of "average radius", instead of actual model. This would also explain why, no matter how thin the player's ship is, AI will never have any problems hitting it. Could a coder take a look and tell me how it really works?

 

Offline Swifty

  • 210
  • I reject your fantasy & substitute my own
Re: How does colision detection work on player?
Collision detection fundamentally works using ray tests. We usually take a vector of an object's last and current position and use it to do a ray test against the other object's individual triangles that compose of it's subobjects if the bounding sphere and subobjectl bounding box checks have passed. If we get a hit and the hit is within the distance magnitude of the last and current position, that hit is registered.

This means that when doing a collision query with two objects, we only check the mesh of one of those objects while the other object is abstracted as the ray vector. For ship to weapon collisions, we check the ship's mesh against the weapon's point position. For ship to ship collisions, the smaller ship's point position is checked against the bigger object mesh.

So as a result, small ships colliding with bigger ships will likely have a portion of their mesh clipping into the bigger ship until the center point finally hits the big ship. It's pretty expensive to do mesh on mesh collisions and I foresee it won't be happening until I get the collision code running faster.

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: How does colision detection work on player?
But then, why did I struck the bay while not really touching it?

 

Offline Swifty

  • 210
  • I reject your fantasy & substitute my own
Re: How does colision detection work on player?
I dunno, is the center point of your ship outside of the model?

  

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: How does colision detection work on player?
Nope, inside it (Scooby's Javelin).
Also, it works like that if I bump into the deck by the top of the fighter, not only the bottom.