|
Post by lyppeterlyp on Jun 24, 2020 20:07:58 GMT
i know how to make combo,but it seemed no option to make a charge attack? E.G press button A is a light attack,but hold on A botton for a while then release is another attack. Guys can you help me?
|
|
|
Post by Invector on Jun 24, 2020 21:06:53 GMT
i know how to make combo,but it seemed no option to make a charge attack? E.G press button A is a light attack,but hold on A botton for a while then release is another attack. Guys can you help me? Try override the method MeleeWeakAttackInput of the vMeleeCombatInput public float minStrongAttackTime = 2f;
/// <summary> /// WEAK ATK INPUT /// </summary> public virtual void MeleeWeakAttackInput() { if (cc.animator == null) return;
float remainingTimePressed = 0;
if(weakAttackInput.GetButtonTimer(ref remainingTimePressed,minStrongAttackTime)) { TriggerStrongAttack(); } else if (weakAttackInput.GetButtonUp() && remainingTimePressed > minStrongAttackTime * 0.5f) { TriggerWeakAttack(); }
}
|
|
|
Post by lyppeterlyp on Jun 25, 2020 15:58:03 GMT
It's really worked,thank you!!!
|
|
|
Post by chairiko on Jul 11, 2020 18:11:02 GMT
How to do this if you're using Rewired
public virtual void MeleeWeakAttackInput() { if (cc.animator == null) return;
if (weakAttackInput.GetButton()) { startTime++; }
if (weakAttackInput.GetButtonUp() && (!meleeManager.CurrentActiveAttackWeapon || meleeManager.CurrentActiveAttackWeapon.useStrongAttack) && MeleeAttackStaminaConditions() && startTime >= 90f) { startTime = 0f; TriggerStrongAttack(); } else if (weakAttackInput.GetButtonUp() && (!meleeManager.CurrentActiveAttackWeapon || meleeManager.CurrentActiveAttackWeapon.useStrongAttack) && MeleeAttackStaminaConditions()) { startTime = 0f; TriggerWeakAttack(); } }
You can replace 90f with the charge time you want to be equal/greater than to
|
|
|
Post by icronos on Nov 22, 2022 7:45:14 GMT
i know how to make combo,but it seemed no option to make a charge attack? E.G press button A is a light attack,but hold on A botton for a while then release is another attack. Guys can you help me? Try override the method MeleeWeakAttackInput of the vMeleeCombatInput public float minStrongAttackTime = 2f;
/// <summary> /// WEAK ATK INPUT /// </summary> public virtual void MeleeWeakAttackInput() { if (cc.animator == null) return;
float remainingTimePressed = 0;
if(weakAttackInput.GetButtonTimer(ref remainingTimePressed,minStrongAttackTime)) { TriggerStrongAttack(); } else if (weakAttackInput.GetButtonUp() && remainingTimePressed > minStrongAttackTime * 0.5f) { TriggerWeakAttack(); }
}
The charge function works with this code but Im getting a weird issue where if I setfloat to powercharge animator it would cause a drop in fps. Im not quite sure what causing the performance issue public class ShooterMeleeInputOverride : vShooterMeleeInput { #region Custom Inputs
[vEditorToolbar("Custom")] [Header("Override Input")] public bool useChargeStrongAttack = false; public float minStrongAttackTime = 2f;
int powerchargerHash = Animator.StringToHash("PowerCharger");
public float powerChargeSpeed = .1f;
private float powerCharge = 0f;
private bool isCharged = false;
[Header("Input Method")] public bool useGetButtonUpForAttack = true;
#endregion
[System.Serializable] public class OnChangePowerCharger : UnityEvent<float> { } [System.Serializable] public class OnFullCharge : UnityEvent { }
public OnChangePowerCharger onPowerChargerChanged; public OnFullCharge onFullCharge;
protected override void Start() { onPowerChargerChanged.AddListener(onPowerCharger); onFullCharge.AddListener(_onFullCharge); base.Start(); }
private void _onFullCharge() { cc.animator.SetInteger(vAnimatorParameters.AttackID, AttackID); cc.animator.SetTrigger(vAnimatorParameters.StrongAttack); shooterManager.CancelReload(); powerCharge = 0f; onPowerChargerChanged.Invoke(powerCharge); }
public override void MeleeStrongAttackInput() { if(!useChargeStrongAttack) { base.MeleeStrongAttackInput(); return; }
if (cc.animator == null) return;
if(strongAttackInput.GetButton() && (!meleeManager.CurrentActiveAttackWeapon || meleeManager.CurrentActiveAttackWeapon.useStrongAttack) && MeleeAttackStaminaConditions()) { float remainingTimePressed = 0;
if(strongAttackInput.GetButtonTimer(ref remainingTimePressed,minStrongAttackTime)) { //release after time onFullCharge.Invoke(); } else if (strongAttackInput.GetButtonUp() && remainingTimePressed > minStrongAttackTime * 0.5f) { //release prematurell=y Debug.Log("Release"); powerCharge = 0f; onPowerChargerChanged.Invoke(powerCharge); }
if(remainingTimePressed > 0) { if(powerCharge <= 1) { powerCharge += Time.deltaTime * powerChargeSpeed; onPowerChargerChanged.Invoke(powerCharge); } else { //power charger > 1 } } } }
private void onPowerCharger(float value) { Debug.Log($"Charging Weapon {value}"); animator.SetFloat(powerchargerHash, value); } }
|
|
|
Post by icronos on Nov 22, 2022 12:36:17 GMT
also I found out theres a possible bug in GetButtonTimer where it never release the inButtonTimer if button was released before intended duration. Had to manually set it to false otherwise it will not trigger GetButtonTimer on the next code execution.
|
|