Categories
Game Development

Debris from reactors

I have debris from shooting reactors now. When the reactor mesh loads, I analyze the mesh and generate a face list, which I store in a cache map with the filename of the mesh as the key. When you shoot the reactor, I take the bullet position and find the nearest face. I then find […]

I have debris from shooting reactors now. When the reactor mesh loads, I analyze the mesh and generate a face list, which I store in a cache map with the filename of the mesh as the key. When you shoot the reactor, I take the bullet position and find the nearest face. I then find the nearest point on that face to the bullet. Lastly, I randomly rotate the face normal within a certain tolerance and use it the vector to shoot out the debris from. I had to account for some transformation problems, such as the face list is in local space, while the bullet is in world space, but I got it working in the end. What this means is that when you shoot a reactor, a piece of debris comes out from the surface of the reactor where you shot it, out away from the surface. Most games just fake it, by spawning debris from the bullet position, but I have damage from a proximity radius, so the bullet doesn’t always directly hit the reactor. This way, the debris still comes out of the reactor.

This technique can be extended more usefully for walls which explode outwards.

I’m not sure if anyone will actually appreciate this, given how far out the game is zoomed, but it’s good practice for me. Just 6 months ago I would have really struggled with this. But with my 3D programmer training at The Collective I not only did it, but in passing reinvented the function to get the nearest point on a plane just from thinking about it for a few minutes.

Next up is when reactors explode, the lights go out and you switch spawn points. This should be no work at all, but it seems like every time I start some minor thing I get sidetracked with a dozen little bugs and changes.

Leave a Reply

Your email address will not be published. Required fields are marked *