Announcement

Collapse
No announcement yet.

Melee Combo Attack Issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Melee Combo Attack Issue

    I finished a melee combo system base on UDK Melee Weapon Tutorial by Mavrik Games : here
    But I have a problem with combo.
    I cant go to second or third attack from first or second attack easily.
    I click the mouse left click quickly, the player just sometime go to second or third attack.
    How I can fix this problem?

    Weapon Class:
    Code:
    function RestoreAmmo(int Amount, optional byte FireModeNum)
    {
    	Swings[FireModeNum] = Min(Amount, MaxSwings);
    }
    
    function ConsumeAmmo(byte FireModeNum)
    {
    	if (HasAmmo(FireModeNum))
    	{
    		Swings[FireModeNum]--;
    	}
    }
    
    simulated function bool HasAmmo(byte FireModeNum, optional int Ammount)
    {
    	return Swings[FireModeNum] > Ammount;
    }
    
    simulated function FireAmmunition()
    {
    	StopFire(CurrentFireMode);
    	SwingHitActors.Remove(0, SwingHitActors.Length);
    
    	if (HasAmmo(CurrentFireMode))
    	{
    		if (MaxSwings - Swings[0] == 0 && CrystalTerraWeaponPawn(Owner).bCanAttack) {
    			CrystalTerraWeaponPawn(Owner).SwingAnim.PlayCustomAnim('b_attack1', 1.0);
    			CrystalTerraWeaponPlayerController(Instigator.Controller).IgnoreMoveInput(true);
    			CrystalTerraWeaponPlayerController(Instigator.Controller).IgnoreLookInput(true);
    			SetTimer(GetFireInterval(CurrentFireMode), false, nameof(Testing));
    		} else if(MaxSwings -Swings[0] == 1 && CrystalTerraWeaponPawn(Owner).bCanAttack) {
    			CrystalTerraWeaponPawn(Owner).SwingAnim.PlayCustomAnim('b_attack2', 1.0);
    			CrystalTerraWeaponPlayerController(Instigator.Controller).IgnoreMoveInput(true);
    			SetTimer(GetFireInterval(CurrentFireMode), false, nameof(Testing));
    		} else if(MaxSwings -Swings[0] == 2 && CrystalTerraWeaponPawn(Owner).bCanAttack) {
    			CrystalTerraWeaponPawn(Owner).SwingAnim.PlayCustomAnim('b_attack3', 1.0);
    			CrystalTerraWeaponPlayerController(Instigator.Controller).IgnoreMoveInput(true);
    			bIsLastHit = true;
    			SetTimer(1.25f, false, nameof(Testing));
    		} else {
    			Testing();
    		}
    		PlayWeaponAnimation(SwordAnimationName, GetFireInterval(CurrentFireMode));
    		super.FireAmmunition();
    	}
    }
    
    simulated state Swinging extends WeaponFiring
    {
    	simulated event Tick(float DeltaTime)
    	{
    		super.Tick(DeltaTime);
    		TraceSwing();
    	}
    
    	simulated event EndState(Name NextStateName)
    	{
    		super.EndState(NextStateName);
    		SetTimer(GetFireInterval(CurrentFireMode), false, nameof(ResetSwings));
    	}
    }
    
    function ResetSwings()
    {
    	RestoreAmmo(MaxSwings);
    	CrystalTerraWeaponPlayerController(Instigator.Controller).IgnoreMoveInput(false);
    }
    
    function Testing()
    {
    	CrystalTerraWeaponPlayerController(Instigator.Controller).IgnoreMoveInput(false);
    	CrystalTerraWeaponPlayerController(Instigator.Controller).IgnoreLookInput(false);
    	bIsLastHit = false;
    }
    Thank You.

    #2
    It looks to me like you should be using Swings[CurrentFireMode] rather than Swings[0] frequently. Also, would try logging MaxSwings, Swings[0] or Swings[CurrentFireMode] and the bCanAttack to make sure that your variables are what you are expecting them to be.

    As an aside, you can also use SwingHitActors.Length = 0 to empty an array.

    Comment

    Working...
    X