Overloading a UFUNCTION

I want to overload a UFUNCTION CanFire() with CanFire(bool, bool)

	UFUNCTION(BlueprintCallable, Category = "Status|Get")
		// Check if character meets the requirements to fire
		bool CanFire() const;

	UFUNCTION(BlueprintCallable, Category = "Status|Get")
		/* Check if character meets the requirements to fire
		 * @param bCheckMovement : true to check movement, otherwise false
		 * @param bFalseIfFiring : true to account for current fire state, otherwise false
		 */
		bool CanFire(bool bCheckMovement, bool bFalseIfFiring) const;

////////// .cpp //////////

// Check if character meets the requirements to fire
bool ADHCharacter::CanFire() const
{
	return GetCurrentWeaponInfo().CanFire();
}

/* Check if character meets the requirements to fire
 * @param bCheckMovement : true to check movement, otherwise false
 * @param bFalseIfFiring : true to account for current fire state, otherwise false
 */
bool ADHCharacter::CanFire(bool bCheckMovement, bool bFalseIfFiring) const
{
	if (!((bCheckMovement && bIsSprinting) && (bFalseIfFiring && bIsFiring))) return GetCurrentWeaponInfo().CanFire();
	else return false;
}

However, this creates an error on compile:

1>  D:/Library Storage/Documents/Unreal Projects/DistantHome/Source/DistantHome/Public/Player/DHCharacter.h(173) : 'CanFire' conflicts with 'Function /Script/DistantHome.DHCharacter:CanFire'

So how do I overload a UFUNCTION?

I want to avoid:

#define CAN_FIRE CanFire(false, true)
1 Like

Hi Dirt113,

if nothing has changed. Overloading of UFUCTION is not possible. Other people asked it. See

maybe it is possible for you to rename the overloaded function in something like this:

 bool CanFireWithParams(bool bCheckMovement, bool bFalseIfFiring) const;

Don’t know which name maybe suit for you.

Have a good day.

2 Likes

Thanks for the reply :smiley: