[Nice 2 Have] Collision - Slide wall

View previous topic View next topic Go down

[Nice 2 Have] Collision - Slide wall

Post by S33m3 on Wed Apr 27, 2011 2:45 pm

I don't know how you want us to report you bugs or nice to have things ?

When you are "colliding" with a wall at less than 90degrees, you should slide alongs it.

The algo for this is easy (something like this) :



Code:

position.X += velocity.X;
if(colliding())
  position.X -= velocity.X;

position.Y += velocity.Y;
if(colliding())
  position.Y -= velocity.Y;

position.Z += velocity.Z;
if(colliding())
  position.Z -= velocity.Z

//colliding definition :

bool colliding()
{
  int minX = Position.X - size.X / 2;
  int minY = Position.Y - size.Y / 2;
  int minZ = Position.Z - size.Z / 2;

  int maxX = Position.X + size.X / 2;
  int maxY = Position.Y + size.Y / 2;
  int maxZ = Position.Z + size.Z / 2;

  for (int x = minX; x <= maxX; x++)
    for (int y = minY; y <= maxY; y++)
      for (int z = minZ; z <= maxZ; z++)
      {
        if(blockType[x, y, z] != 0)
          return true;
      }

  return false;
}

S33m3

Posts : 54
Join date : 2011-03-23

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum