Advanced Melee

This package includes an advanced and highly customizable melee system, with optional mechanics, such as feints, parrying and disarming.

Quick Setup Guide
  • Install the Advanced Melee package to your project
  • Either add the SwordTemplate to the Item Template property in User template’s inventoryDefaultScript or drag the SwordPickUp template to the game world
    • If your project doesn’t include the default Inventory package, you can install it from the community
      tab
Picture

  • If you want to use the stamina, add StaminaPlus and StaminaPlus UI templates to the Player template
    *For more info on how to customise your stamina check out the Stamina Plus - Package Guide by Cykocys.
Picture


Overlook

The Advanced Melee System uses three different templates to represent the melee weapon in different situations:

SwordTemplate

SwordTemplate is the template used when the weapon is equipped by the player. It’s composed of four entities: a locator called SwordTemplate, that has the meleeScript attached to it, a locator called HandLocator shows where the weapon will be grabbed, a Weapon entity that works as the weapon’s 3D-model and MeleeTrigger, that is used to detect the attacks.

meleeScript Properties
  • Uses Stamina: Determines, if your melee system uses stamina(You need to add StaminaPlus to the Player template)

  • Swing Without Stamina: Determines, if you can swing with low stamina

  • Primary Damage Amount: How much damage the attack causes

  • Primary Wind Up Time: How long it takes for the attack to start

  • Primary Lunge Amount: How much you move forward on attack

  • Primary Push Strength: How much your attack pushes the target backwards

  • Primary Stamina Cost: How much Stamina the attack costs

  • Primary Attack Input: The button input, that you use for primary attack

  • Primary Msg: The action name showed in the input prompt for the player

  • Has Secondary Attack: Can the player choose between two attacks

  • Secondary Attack has its own versions of all the properties attached to the primary attack.

  • Can Throw: Can the weapon be thrown

  • Throw Damage Amount: How much damage the throw causes, when it hits

  • Throw Projectile Speed: How fast the thrown weapon flies

  • Projectile Template: Add the template of your weapon projectile here (more info below)

  • Throw Input: The button input, that you use for throw

  • Throw Msg: The action name showed in the input prompt for the player

  • Can Parry: Can parry enemy attacks. Parry is a sword fighting technique where you deflect an attacking enemy’s sword with your sword.

  • Parry Window: How long player stays in the parrying state after pressing parry

  • Parry Stamina Cost: How much stamina the parry costs

  • Parry Input: The button input, that you use for parry

  • Can Riposte: Can riposte after parry. Riposte is a sword fighting technique where you quickly attack your opponent right after your parry, by using the momentum from their attack.

  • Riposte Window: How much time you have for initiating the riposte after a successful parry.

  • Riposte has its own versions of all the properties attached to the primary and secondary attacks.

  • Feint Msg: The action name showed in the input prompt for the player

  • Can Feint: Can cancel the started attack, to fake out opponents.

  • Feint Stamina Cost: How much stamina the feint costs

  • Feint Input: The button input, that you use for feint

  • Feint Msg: The action name showed in the input prompt for the player

  • Can Clash: Adds a mechanic, where two characters hitting each other at the same time, both get parried, instead of damaging each other.

  • Clash Window: After registering a hit, the script waits for this amount of time to see, if there’s a clash (Big value can cause the damage to happen with a lot of delay)

  • Can Be Disarmed: Adds a mechanic, where getting parried can cause you to drop your weapon. If you use stamina, the disarm happen’s, if your stamina is 0 at the moment of parry. Otherwise it will happen on any parry.

  • Disarmed By Clash: Can the weapon clashes cause a disarm

  • Pick Up Template: A template spawned in the world when you get disarmed. Also used, when throwing the weapon at a close by target.

  • Input Buffer Time: In order to keep the gameplay feeling consistent, this script saves the player’s inputs into a buffer, to wait for the action to be available. This property determines how long an input stays in the buffer.

  • Attack Sound: The sound played, during the swing

  • Melee Impact Sound: The sound played on successful hit

  • Attack Effect: The effect played on successful hit

  • Parried Sound: The sound played, when parried or clashing

  • Parried Effect: The effect played, when parried or clashing

  • Melee Trigger: The trigger used to detect hits.

  • Weapon: The weapon’s 3D-model in character’s hand

  • Default Grip: Grip used to determine the swing animation on primary attack(Should only be either Pistol or Knife).

  • Alternative Grip: Grip used to determine the swing animation on secondary attack and parry(Should only be either Pistol or Knife).


SwordProjectile

SwordProjectile is the template used when the weapon has been thrown. It’s composed of two entities: a locator called SwordProjectile, that has the thrownProjectile attached to it and a Weapon entity that works as the weapon’s 3D-model.

thrownProjectile Properties
  • Lifespan: How long the projectile can fly without hitting anything, before stopping
  • Hit Effect: The effect played, projectile hits something
  • Hit Sound: The sound played, projectile hits something
  • Sword: The weapon’s 3D-model
  • Pick Up Template: A template spawned in the world when the projectile either hits something or runs out of lifespan

SwordPickUp

SwordPickUp is the template used when the weapon is set in the world and can be picked up. It’s mostly your normal pick up template.

SwordPickUp properties

pickupSpawnerScript has two important properties:

Use Self As Template: Should be set false
Pickup Template: Add the weapon’s template here (in the default case SwordTemplate)


How to make a new weapon
  1. Duplicate the SwordTemplate and name it. Recommended naming convention is ‘weapon’s name-’Template. For example AxeTemplate.
pic

  1. Open the new weapon template and change the Weapon entity’s Mesh Asset to the weapon you want.
pic

  1. Move the Weapon into a position. The HandLocator’s bottom should touch where you want the character to hold the weapon
pic

  1. Move and scale the MeleeTrigger to fit the weapon. Make the trigger extend past the tip of the weapon (the more it extends past, the easier it is to hit with) and extend it towards the swinging direction(like with the default template), to help with script’s swing prediction
pic

  1. Duplicate the SwordPickUp and name it. Recommended naming convention is ‘weapon’s name’-PickUp. For example AxePickUp.
pic

  1. Open the new pick up template and change template’s Mesh Asset to match the weapon template you created earlier.
pic

7.Add the weapon template to the pickupSpawnerScript’s Pickup Template property

pic

  1. If you don’t want to make the weapon throwable, skip to step 12
  2. Duplicate the SwordProjectile and name it. Recommended naming convention is ‘weapon’s name’-Projectile. For example AxeProjectile.
pic

  1. Open the new projectile template and change the Weapon entity’s Mesh Asset to match the weapon and pick up templates.
pic

  1. Add the pick up template to thrownProjectile’s Pick Up Template property.
pic

  1. Go back to the weapon template and add the pick up template into Pick Up Template property of meleeScript
pic

  1. If you want the weapon to be throwable, add the projectile template to the Projectile Template property of meleeScript
pic

  1. Setup script properties on meleeScript, the way you want them. These will determine the weapon’s stats and the behavior (you can find a description of what each property does in the Overlook section of this guide).

Credits

This package uses the brilliant Stamina Plus package by cykocys

8 Likes

I want to comment that I love your package but you have to add one thing in the use of stamina. In meleeScript you call the GetStamina function but in SPCore there is no such function. Just add this and it will work for you in SPCore:

function SPCore:GetStamina()
	return self.properties.Stamina
end
1 Like

I must have included a wrong version of SPCore, with the package. I updated the meleeScript to use that default SPCore functions, so it should now work with any version of StaminaPlus.
I also added a riposte mechanic, while I was at it.
Thank you for letting me know.

1 Like

I just updated and it is working even though you have put the strong attack button and the parry button in the same (secondary). In case you want to change it to a different one. Thank you very much

1 Like

When I try downloading the package on an empty project, the parry seems to come bound to secondary and strong bound to interact. I did change the parry and strong attack’s inputs between each other. I think that might have caused an artifact on your side, when updating. Sorry for the inconvenience.

1 Like

No problem at all, I want to help u because u are awesome!

1 Like