Monday 2 January 2012

Making my landing zone

So I need a way of checking the type of collision that has occurred.

For now I'll just have a boolean that states if the collision is safe.

So I need to determine what is a safe and unsafe collision.

If it hits the side its unsafe, if it hits the top then It's safe.

I could do all sorts of things like calculate the intersecting path to determine the plane intersected.

But my needs are simple.

If the intersection occurs and the max.Y of the player UFO bounding box is less than the max.Y of the building block bounding box then it can't have hit the top. So its unsafe.

Otherwise it must have collided with the top, therefore assume it's safe? Not quite.

The player UFO can just barely touch the top of the building block to cause an intersection and it will be considered safe. Which looks silly as it looks like the player UFO is balancing on the edge of a building. Really it should crash.

Again this isn't a hard check. If the player UFO has has collided with the top of the building and the player UFO bounding box x and z min and max limits is contained within the x and z min and max limits of the block bounding box, then it can be considered the player UFO has landed safely and is not over hanging the building at all.

So now I have the means to know if the building collision is safe or not.

I need to make this more challenging later based on the speed of the player descent. If you come down too fast then you crash land and die (just like in lunar lander)

But for now I have the basics of a game. I have my map and a controllable player that can collide with the landscape.

It works pretty well, the one annoying thing is you never really know exactly where the player UFO is hovering over so before you start your descent you can't be sure if you will crash.

This was a problem in the 2D version of the game too, and I solved it with a player shadow showing which building you were over.

So shadows are still in my opinion the easiest game mechanic to aid the player in knowing their position and helping them to a safe landing.

No comments:

Post a Comment