FTimerDelegate Throws Vague Exception

Janyx
Sun, 25 Mar 2018 19:21:39 +0000
C++

I am trying to implement an weapon swapping system using the FTimerDelegate. The basic Idea is that equip is called once holster is finished. I declare my FTimerDelegate like so:

UCLASS()
class AXLCharacter : public ACharacter
{
	GENERATED_BODY()

public:

        // .....

	FTimerDelegate TimerDelegate_SwitchWeapon;

        //...
}

My code that implements the FTimerDelegate is below:

float AXLCharacter::EquipWeapon(uint32 Weapon)
{
	float Duration = 0.0f;
	if (CharacterWeapons->Inventory.Num() > 0)
	{
		if (CurrentWeapon)
		{
			float Duration = HolsterWeapon() * 10;

			TimerDelegate_SwitchWeapon.BindUFunction(this, FName("EquipWeapon"), Weapon);
			GetWorldTimerManager().SetTimer(TimerHandle_SwitchWeapon, TimerDelegate_SwitchWeapon, Duration, false);
		}
		else
		{
			try
			{
				CurrentWeapon = CharacterWeapons->Inventory[Weapon];
				Duration = CurrentWeapon->StartEquip("RightHand");
			}
			catch (std::exception const & ex)
			{
				ex;
			}
		}
	}
	return Duration;
}
float AXLCharacter::HolsterWeapon()
{
	float Duration = 0.0f;
	if (CurrentWeapon)
	{
		Duration = CurrentWeapon->StartUnequip();
		CurrentWeapon = NULL;
	}
	return Duration;
}

The initial equip works great and holster the weapon works great. But when switch the holster section of the code run fine a the timer successfully calls equip. but when trying to execute the code DelegateInstanceInterface.h throw the following exception:

This give me no information, I have no idea what the issue it. If someone has any ideas – I would appreciate the help

1 post - 1 participant