Melee attack

I guess the rewrite has paid off a little, when I added a new attack, I only had to add a new weapon as the claw by duplicating the original chest gun, change the name, the texture for this attack and a new script for the behavior.

A departure from original attacks, which were simply ranged attacks with bullets, this time I made a attack based on the claw. What I had in mind was the zoid running forward to the enemy and slashing. With the state architecture up, I could write the state changes and their conditions and prerecord it in a script, since the zoid moves according to the state, not directly according to the player input so I can hack into the motion handle.

Since the swinging motion of the claw essentially means that the damage is dealt when something with health stats is found along that arc. However, without the benefit of pin point physics and animations, I had to think of another way to find the collision.

spherical cow.jpg

For the bullet damage, I used rays to find the hit. For this melee attack though, in the sprit of the spherical cow, I found this: Physics.OverlapSphere(origin as Vector3, radius as double), which served nice for a collision check. While this does not provide the the angle of attack (which I could have obtained by subtracting the position vectors of the victim and the claw, albeit this is kinda screwed), it does provide a way for me to find the hits, since most of the sphere is in the body of the zoid, but the outer parts, which formed a perfect arc, was the place of attack.

With no bullets here, the original Bullet_Handle which shoots the bullet, was converted into a new script called Claw_Mech which directly did the attack.

Then it was just salt and pepper coding. A little modifications there, changing variables here. :P Yay! Another milestone done, I guess. Hopefully Baws will finish the health bar before next week so we can complete the game play system in two months. :D

 
1
Kudos
 
1
Kudos

Now read this

Pattern Muse

As I commenced the rewriting and porting of my code to Github, I felt amazed on how the heck I could have developed the game without coughing blood six months ago. All the .blend, .boo, .cs, .prefab etc files together, with all sorts of... Continue →