Post news RSS Wednesday 15.6 & Thursday 16.6 | Combat

I got a little excited when I got the combat actually playable and worked on it for way too long. Got a lot done though.

Posted by on

Wednesday 15.6 & Thursday 16.6 | Combat

Platformer Prototype

I got a little excited when I got the combat actually playable and worked on it for 13 hours on Wednesday. So yeah, today I'm just gonna write this and take it easy. On Wednesday though, the combat started to look and feel pretty good already. I'll still have to mess around with the camera, figure out how to visualize the enemy's health and add a lot of things, but that's gonna be after getting the stealth mechanic working and seeing how it all plays out. On my blog

Kicking to Keep Player at Attacking Range

I had trouble keeping the player at a hittable range. The problem wasn't only that the enemy wouldn't hit but more that the enemy got "pushed" when trying to move back to the hittable range. It probably could've worked with some precise movement, but that means a lot of time for polishing. I thought a more interesting way to keep the player at a distance would be a kick.

36Kick

This seemed like a great idea but still required some coding for the push. In the end I decided that this wouldn't be an obstacle for adding it because the pushing code would probably get used a lot in the future. Currently the actual push is just roughly timed and the strength over time is controlled with an animation curve and I don't think that that's going to be changing because it really might not even matter.

The kick ended up being a great and time efficient way of preventing the player from drilling the enemy's shins to dust.

37GlobalCombatManager

Weapon Swinging and Impact Sounds

I also got some great sounds in, thanks to Eponn on FreeSound.org. The WeaponInfo ScriptableObject has a list for swinging sounds and impact sounds (per weapon of course). Then when swinging I just get a random one different from the previous and play it with the help of an AudioSource pool.

About the weird attacking behaviour code

I decided to disable behaviour tree evaluating totally while the enemy is dead or disabled. After this I got almost all of the functionality out of the EnemyBehaviour and into the behaviour tree nodes.

Work Done

  • Player now takes damage and reacts too
    • Player's movement and angular speed controllable when attacking
    • "Character" script for holding the player's state and everything associated (IDamageable, Stats, Reacting to hits)
  • Refactoring and better segmenting a lot of Character Controller code => More readable, easier to debug, easier to add more functionality
  • Global Combat Manager for easy testing/balancing of combat
    • Holds parameters for combat such as
      • Threshold of damage after which an enemy or player reacts (the animation)
      • Movement and angular speed when attacking
  • Enemy
    • Modified primary attack animation to always hit when straight ahead (swung to the side before)
    • Kicking
      • When player gets too close the enemy kicks him
      • Meant adding a pushing mechanic to the character controller
        • Did with Vector3 PushVelocity
        • When PushVelocity is not zero, override the normal movement loop
  • Very simple Player hp and enemy hp UI
  • Weapon
    • OnSwing animation event to play swing sounds
    • Hit & Swing sounds (Thanks to Eponn on FreeSound.org)
    • Hit and getting hit haptics
  • AudioSource pool with main method: PlaySoundAtPosition()
    • This method finds an available audiosource from the pool, if on eis not found it gets instantiated
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.