Showing posts with label Line of Sight. Show all posts
Showing posts with label Line of Sight. Show all posts

Friday, February 14, 2014

Update 30: Line of Sight

I've managed to implement a simple line of sight mechanic with ray casting. If my character can't see an enemy - because they are behind another object and therefore, not in 'line of sight' of my character, I hide the mesh renderer on the object, effectively making it invisible. 




The great part about this solution is that the enemy character is still there and it's AI is still running. When the enemy character comes back into view again, I just enable the mesh renderer. Every time a character moves, I ray cast between each character and enemy to see if they are visible and then hide and show the enemy character depending on if they are in the line of sight of my player.

Here is a sample where I can't see the enemy (although, because I haven't yet replaced the UI of the enemy characters, you can see their health bars - this will be fixed later):




And here, after I move around the obstacle, I can see the enemy character again.



Monday, September 30, 2013

Update 21: Alpha 1.57 - Upgrading the character model

With the timing fixed, it was time to take the next step in implementing line of sight. 

An early line of sight mechanic highlighted how simple my character models were. As my characters are still just a single object (cylinder), cover effectively made my targets invisible if the one point of balance in the center of the cylinder was behind cover. It was time for me to develop my characters a little, to have multiple points (head, arms, body, etc).

Heading to my sketchpad again, I tried to design a simple model about the height and width, with arms, legs, a body and head.





The new model ends up looking a bit like this (with the old model to the left). It's a little silly looking, but is enough of a person for me to continue building the game engine.


What does he look like in a level? This is some basic animation I am using to aim at a target (The right arm is at 90 degrees - like I said "BASIC"). There is still a long way to go, but this is at least an upgrade from the cylinder.