Tuesday, 30 July 2013

Combat AI, Navigation and Screenshots

So recently I've been looking at my combat AI, so far I've made do with it getting so close to the player and sitting still and shooting until the player moved out of range, it lost sight of the player or the player killed it. That's not good enough though, in terms of game play it is really predictable and lacks any sort of adrenaline or challenge. Well unless about 20 of these enemies surrounded you and just opened fire.

Of course this was just a temporary combat mechanic designed more for testing other functionality such as line of sight, my finite state machine and weapon controls. But now the time comes for something more advanced.

Initially I thought about terrain analysis and tactical assessment on the fly, something I'd be forced to do if I was working with robotics or something more physical but that idea rapidly gave way to storing valuable information on the map.

So to my scene I added a node named "Cover" to this node all objects that could be used as cover would be attached, things like crates, sandbags maybe a table. Things to obscure the line of sight but still allow the AI to shoot at the player. This list of cover objects would then be loaded and stored in an object designed to provide global information to the NPCs. An object which could also be used to relay communications between troops alerting other allies if they have a man down and should be on alert for the player. But enough of that I'm getting sidetracked (maybe if I updated more regularly I could have wrote about this in another post).

So I had my cover list and I changed the finite state machine to get the AI to put cover between it and the player upon sighting the player. And one thing became clear. The player just walked through the cover.

So I regenerated my navigation mesh trying to get it to account for static scenery and found that the JMonkey navmesh (which in turn is a wrapper for a previous version of the critterai library) doesn't factor in other models for the navmesh.

Right now I saw two choices:

  1. Edit the source code to fix this
  2. Use the navmesh pathfinder for a generalised path then tweak this dynamically to avoid obstacles
Upon looking at the source I decided to go for option 2. Plus it would allow for objects to move from start position which is definitely more flexible.

So how to do this...

Well here goes my method.

I cloned the bounding boxes of all cover objects as you can't get dimensions from models directly. I then added the radius of my AIs collision shape to this. The reason for this is when checking if the AI can fit between two obstacles its easier to expand the bounds for the obstacle and shrink the AI down to a point with an infinitely small width. 

Then any overlapping bounding boxes I merged as the AI couldn't fit between those two obstacles. I then performed ray casts between each pair of adjacent way points on the path checking for intersections with the bounding boxes.

Any bounding boxes I collided with I took the position of the midpoint of the segment of line that intersected the box. Then I created a vector starting at the centre and moving to the midpoint and extended that by the width of the bounding box. 

For a tighter fit I might want to perform another raycast to find the edge of the box were the character can walk and just brush the sides of the obstacle (remember I extended the bounding box) but for now I'm happy with this fix. It's still a work in progress and I've still got to fully test how far I've built before optimising it.

So without further ado a screenshot. The blue box is the AI, the grey box some cover, the pink dot is set above the centre of the bounding box (which is invisible), the cyan dot above the midpoint. And finally the red dot is the detour point to avoid hitting the cover.

The green line I drew in to show the ray going between the end way point behind the cover and the one prior to it.

Cor' blimey check out that FPS!
Now because I don't want anyone to think that because of the ugly character I made last entry I'd forsaken the human race and shifted my allegiance to the people of cube here is a screenshot of my last player texturing effort:

I'm quite proud to say it, the skin was made in photoshop by brush. I used these brushes and followed the tips http://www.brusheezy.com/brushes/1752-skin-textures-v1 they've also made my clone brushing look smoother can't recommend them enough!


Thursday, 4 July 2013

Finally! A "Properly" Textured Human

Well I've done it, through the power of youtube I've managed to find a good way of texturing humans. No more trying to paint onto meshes or UV layouts desperately trying to achieve the accuracy needed despite the bumps and protrusions of a human body. No more labouring under the hot sun looking for a friendly face and despite my efforts being confronted by grotesque homunculi.

By projecting from view (with bounds) I create a UV layout of one face of my model. I then apply a normal picture of a person as the texture texturing that side of the model. With the clone brush That single side is painted onto the corresponding area of the full UV layout.

Tis truly a thing of beauty. I take this simple man: http://fanart.tv/fanart/tv/248834/characterart/last-man-standing-2011-4ffb175969e71.png

I then apply him paint and I achieve:


Now naturally I won't use this man in the game and all rights belong to whomever took that picture. And the texture was only just lined up but it looks bloody good. I'll try and find some models to take photographs of or create my own computer graphicsy people that are of comparable quality to the resolution blender paints at and then huzah. The people are done.

Of course credit were credit is due I wouldn't have done it without this great tutorial:  http://www.youtube.com/watch?v=p4ngVoGIj1Q  

Now naturally this wasn't as easy as it seems, something had royally messed up in blender and I couldn't see the clone brush but by linking my scene to a blank project I was able to use the clone brush without having to burrow into blenders settings and find out what had gone wrong.

Monday, 1 July 2013

So Pretty.

Textures are wrapping correctly, and animations exporting correctly, the next stage in graphics is to make some nice textures for characters.

However my art skills may not be what they once were:

Hey good lookin', whatcha got cookin' ?
It's nice to see real progress is being made, I feel half of the work left on the game is polishing it up to add that professional touch.