Hello all...
im trying to make 2D side view, strategy game for browsers... basically you have your base on left side, enemy base on right side, and both keep sending troops from one side to other, trying to win... (similar genre:
http://armorgames.com/play/4071/warfare-1944 ) well mine is with zombies.
anyways, what im having problem with...
i programmed soldier to shoot at zombies, it uses raycast (distance 7) to determine if there is any zombie in that area, and when it is, it stops and spawns bullets and sends them towards zombies... thats fairly simple... and zombies have trigger event that destroys bullet and removes health from them.
but now here is the catch, when that soldier gets overrun by zombies, for example 10 zombies attack a soldier, those 10 zombies all have raycasts too, and they all stop at distance 1, from soldier (for melee attacking)
then soldier attacks multiple zombies at once, because all zombies are aligned in a line (distance 1 from soldier). and all zombies have trigger event, and when that bullet reaches that line where zombies are, it damages all zombies standing at distance 1 from soldier... i dont want it like that, i only want it to hit 1 zombie...
so any ideas how to do that? there must be a way but im not seeing one... :/
the only solution that i came up with, was to generate random number from 0.8-1.2 and then use that for zombie raycast, and then they would stop at different distances from soldier, but there's got to be nicer solution than that...attachment 1: shows how soldier FSM is set up, and shows how raycast is set up
attachment 2: shows how zombie Trigger FSM is set up, that detects bullets and destroys them and removes health
attachment 3: shows how zombie raycast is set up...after i get the answer... i will try to do it for melee combat too, because it has the same problem