Why did you remove ability to override CanJump purely in C++?

Dear Friends at Epic,

The ability to override CanJump using only C++ has been removed!

Why are you doing this?

Please dont make it a trend to force things to be done in BP, as the only option!

Especially if we used to be able to do it just in c++ by overriding a virtual function!

What if I had implemented logic in C++ that I cant easily convert into BP without re-writing a lot of my game code?

I was actually creating a custom implementation purely in c++ which I now have to find a way to convert into BP

please dont do this…

Rama

/**
	 * Check if the character can jump in the current state.
	 *
	 * The default implementation may be overridden or extended by implementing the custom CanJump event.
	 * 
	 * @Return Whether the character can jump in the current state. 
	 */
	UFUNCTION(BlueprintCallable, Category="Pawn|Character")
	bool CanJump() const;

protected:

	/**
	 * Customizable event to check if the character can jump in the current state.
	 * Default implementation returns true if the character is on the ground and not crouching,
	 * has a valid CharacterMovementComponent and CanEverJump() returns true.
	 * Default implementation also allows for 'hold to jump higher' functionality: 
	 * As well as returning true when on the ground, it also returns true when GetMaxJumpTime is more
	 * than zero and IsJumping returns true.
	 * 
	 * @Return Whether the character can jump in the current state. 
	 */

	UFUNCTION(BlueprintNativeEvent, Category="Pawn|Character|InternalEvents", meta=(FriendlyName="CanJump"))
	bool CanJumpInternal() const;

Hi!

CanJump is implementable in C++, but because we wanted to expose it as a BlueprintNativeEvent as well, the syntax required is not ‘just’ a virtual function override.

In your header:

virtual bool CanJumpInternal_Implementation() const OVERRIDE;

in your CPP:

bool AMyCharacter::CanJumpInternal_Implementation() const
{
    return true;
}

Thanks for the reply Tom!

But I do not see the function you show above in 4.2 release as obtained from source files on GitHub

I am confused as to why you are showing an OVERRIDE for a function I do not see anywhere.

Is it just that I have to add this function signature, even though there is no base function to override?

Here’s all that I have related to CanJump in Character.h

So as a result I still cannot implement CanJump in CPP

/**
	 * Check if the character can jump in the current state.
	 *
	 * The default implementation may be overridden or extended by implementing the custom CanJump event.
	 * 
	 * @Return Whether the character can jump in the current state. 
	 */
	UFUNCTION(BlueprintCallable, Category="Pawn|Character")
	bool CanJump() const;

protected:

	/**
	 * Customizable event to check if the character can jump in the current state.
	 * Default implementation returns true if the character is on the ground and not crouching,
	 * has a valid CharacterMovementComponent and CanEverJump() returns true.
	 * Default implementation also allows for 'hold to jump higher' functionality: 
	 * As well as returning true when on the ground, it also returns true when GetMaxJumpTime is more
	 * than zero and IsJumping returns true.
	 * 
	 * @Return Whether the character can jump in the current state. 
	 */

	UFUNCTION(BlueprintNativeEvent, Category="Pawn|Character|InternalEvents", meta=(FriendlyName="CanJump"))
	bool CanJumpInternal() const;

Okay just adding the function you describe worked, though all of this is exceedingly new to me and undocumented.

I should probably create a wiki on this…

Thanks Tom!

Rama

You wont see it in the class header for ACharacter because it is part of generated code now (inserted into the class via the GENERATED_UCLASS_BODY() macro). The implementation is there, you can find it in Character.cpp.

That’s terribly confusing for people I think could you make sure everyone avoids sticking stuff into places we can’t easily search for when perusing the code base?

I would not have figured this out any time unless you explained to me, as I normally search the .h files to look for virtual functions to implement :slight_smile:

Rama

I agree that BlueprintNativeEvent is a little bit of a black art at the moment!

hee hee!

:slight_smile:

Rama

Where is this wiki?

This post is over 4 years old and there are possibly a few changes from when this question was asked. What are you trying to find exactly?