Posted on 2011-12-05 in Stingray Incursion
Yes... there are finally some gameplay elements.

If you expected to see some gameplay footage though, sorry to dissapoint. But I have sort of completed the shooting. This followed from my chat to Danny from QCF Design after Wednesday's game dev session. Basically it went something like : "You say you're writing a game, but there's no gameplay..?" "Um..yeah.."

I was looking for a way to determine an exact hit. Until now I targeted the objects using the bounding boxes. It's fine to know what your aiming at in the general area, but not good enough to determine what exactly you are hitting. So I got an idea last night as I lay in bed, got up, and tried it out. As it turned out, it only worked in my head. But I then I found another solution, and that worked like a charm.

The chorus goes something like this:

  • Find the ray that is the gun sight
  • Use that ray and object bounding boxes to find potential targets
  • Test every object found if there is an exact hit based on the point in triangle method
  • Now I know exactly which object is hit, and I know precisly where that object is being hit based on the UV coordinates

Two things here to note: Firstly, I already have a FOR loop to determine viewable objects in a pre-process method. I implemented these steps into this same FOR loop, otherwise you're doubling up on CPU time going through the same list of things. Secondly, when using the point- in-triangle method, I use my lowest detail models. They closely mimick the shape and size of the high detail versions, and there's no point in hit-testing detail. You're only interested in the bottom line - is it hitting exactly and where is it hitting? If I was writing Battlefield 4, then yes I'd use the higher detail versions to determine of an overhead power cable is being hit and break apart and spew electricity on everyone :)

All that was left to do now was to pass a couple of event handlers around to effect the damage dealt by the gun. This actually happens per round being fired. I have a single particle system, attached to the chopper, that generates one particle for each round being fired. Each particle is assigned it's target at the time of creation based on what the chopper was targeting at that specific time. When it expires it triggers its event that is hooked up to the linked object and some method calls sorts out the rest.

So, I finally have some real gameplay. Go figure :)

Other posts in Stingray Incursion
I'm on a roll man! The few vehicles (actors) on my test level are now roving around, following thier randomly generated patrol routes.
So when you're going up a hill, you're going up a hill, right? Not so easy when you're coding it.
I decided that after the quantum leap of the last week or so, I needed to refine what I had done. Both in artistic appeal and technical implementation.