Back

Tuesday 7.6 & Wednesday 8.6 | Melee Combat

Platformer Prototype

Tuesday stretched a little longer than I would've wanted to. A lot got done on the detection and damage system though. Wednesday I spent on making minor fixes all around and getting the attacks to feel more responsive.

Damage & Detection System

Detection

Detection system got a lot of new stuff including:

  • 2 ways for detecting hits
    • SphereOverlap
    • Raycasts back and forward

Sphere Overlap is used to find clean hits and raycasts are used find hits where the blade has gone through the player in one frame (collision detection therefore missing it).

Damage

I had a couple of ideas for the damage system, one being calculating the damage for every detection point and the other being velocity based attacks. The first one felt nice but is a total pain to implement thanks to the complexity. The velocity on the other hand made the hits feel random.

Finally I ended up with a per point calculations with position of the points scaling the damage linearly (Closer to the tip deals more damage). The point closest to the handle dealing 1/10 (amount of points) the damage and the very tip dealing full damage.

This damage also scales the effects which are up next.

Effects

For every detection point that has hit there is a ParticleSystem instantiated or placed from pool. I created an empty object and a "MonoBehaviour" to hold and manage these, called "ParticleSystemPool", which does the following:

  • Instantiates new ParticleSystems when needed
  • Places them
  • Scales bursts based on damage
  • Plays the effects

Using "Any State" Transitions for Responsive Attacking

AnimatorAttackAnyState

Rolling Fixed

Switched from using root motion to just locking the direction and adding some speed. Can't see a difference and feels a 100 times better. Before even the smoothed camera got weird because the root motion was so jittery.

Pictures

WeaponManagerEditor

WeaponManager Editor


SwordEditor

SwordEditor


WeaponTypeScriptableObject

WeaponType ScirptableObject


AttackAnimationEvents

Attack Animation Events


Work Done

  • Hit detection system
    • Now has 2 ways for detecting
      • SphereOverlap (After which a raycast is used to determine the point where effects are played from)
      • Raycasts back and forward
    • A lot of polishing and debugging
  • Damage System (Calculated per detection point)
    • Blade position based damage (Closer to the tip deals more damage)
    • (Wednesday) Offset the impact of position based damage to get true max damage of weapon (Still has small bug)
    • Animation events start and stop the damage dealing and hit detection
  • Hit effects (ParticleSystems only, per detection point)
    • "ParticleSystemPool" which holds the particle systems
      • Instantiates when needed
      • Places the effects
      • Scales bursts depending on damage
      • Plays the effects
  • Weapon system
    • "Weapon Manager" on player which holds "WeaponBehaviour equippedWeapon"
    • "Sword" is on the weapon and derives from "WeaponBehaviour"
    • "WeaponBehaviour" holds the parent of the blade line parent and a ScriptableObject "WeaponType"
    • "WeaponType" Holds the weapon's max damage and attack speed (only max damage is implemented as of now)
  • Fixed rolling (Wednesday)
    • No more root motion because it made the character go through walls
  • Fixed attack timings (Wednesday)
    • Transitions come from "Any State" state so it doesn't matter if asomething else is playing but cooldown is off
Back