NavLink and making AI jump?

another thing to keep in mind, AreaFlags NEVER changes to two… how can I change it to two??


I also tried using FVector:: Dist with the distance between the link and the AI, it crashes the engine to try :(… so getting the distance between the link and the AI to activate is out of the question Dx

If you have your [FONT=Lucida Console]UUNavArea_Jump::Jump == 1 then[FONT=Lucida Console] if (AreaFlags >> 2) will always fail. You really need to read those bit flags tutorials :wink:

I just had a throughout read of the code you’ve posted and it seems you’re never setting your navigation area’s flags! You need this piece of code in your area’s constructor:

UUNavArea_Jump::UUNavArea_Jump(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
    AreaFlags = (1 << UUNavArea_Jump::Jump);

You must have missed it from my initial description of how to pull this off with C++. This is required for navmesh generation to know this area represents “jumpable” connections.

Measuring distance between two valid vectors will never crash, which means you’re either trying to extract a location from a NULL pointer or passing some NaN values. I’d suggest you investigated that since it suggests you’re assumptions are wrong somewhere.

ok, correct me if I’m wrong, by doing this (1 << UUNavArea_Jump) when jump = 1, it will equal 2.
cause as I remember from binary, it would go up like this 1,2,4,8,16,32, etc… and that’s shifting it to the left. but wouldn’t shifting it to the right make it zero?
because if AreaFlags always equals 1, then it would look like this 0000001. Meaning shifting it to the left would be the case? (AreaFlags << 1) would then be 000010 making it 2 right??? thus when in the constructor code i forgot in my UUNavArea_Jump code would make the AreaFlags = 000010 if shift 1 to the right which would be the (1 << UUNavArea_Jump::Jump).

Sorry for this explanation… I just want to clarify if this thought process is correct MieszkoZ. Respond if this is either incorrect or correct.

I’m sorry, but I don’t think I understand what you’re saying :slight_smile: But if I do note that[FONT=Lucida Console] (AreaFlags >> 2) means shift right two bits, which turns 2 into 0.

Ok now if i say

if(AreaFlags << 1)
     //Do Stuff

it should check if the AreaFlags is 2 right? cause the binary slot would look like this 000010 which should be two. Another question I have is why does my AI lose movement when the player is on a linked NavMesh. only way i can get movement is if it’s on the exact same navMesh together.

No. “if(AreaFlags << 1)” passes if AreaFlags multiplied by 2 (equivalent of shifting left 1 bit) is not equal to 0. You just need to check if your flag is set amongst all possible flags in AreaFlags which in your case means simply bit-anding AreaFlags with 0x2.

Move request fails because only a partial path can be found and as such is a pathfinding failure. AI accepting or not partial paths depends on specific configuration.

Can you explain/show how I can do this?? :frowning: . I really am trying to understand how to get this going.

How can i make it find all of the paths??

You just need this in your movement component:

void UMyPathFollowingComponent::SetMoveSegment(uint32 SegmentStartIndex)
	const uint16 AreaFlags = FNavMeshNodeFlags(Path->PathPoints[SegmentStartIndex].Flags).AreaFlags;
	const uint16 JumpFlag = uint16(1 << UUNavArea_Jump::Jump);

	if ((AreaFlags & JumpFlag) != 0)
		// jumping code here

and remember to properly set [FONT=Lucida Console]AreaFlags for your navigation area:

UUNavArea_Jump::UUNavArea_Jump(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
    AreaFlags = (1 << UUNavArea_Jump::Jump);

Not setting [FONT=Lucida Console]AreaFlags to proper value was the reason it was not working for you initially.

Regarding partial paths these should get accepted by default, so I’d need to know your exact setup to be able to say more. I suggest you debugged your issue yourself - you’ll need the knowledge how to do it eventually anyway :slight_smile: When debugging failed pathfinding [FONT=Lucida Console]UNavigationComponent::GeneratePathTo is a good starting point.

Thank you for sticking with me to help :)… I’m probably not the only one watching this thread too Dx.

As for this, the image below is my initial setup I have for the NavLinks. I was using the SideScroller Template level to see if it would work really.


basically, I have a Link to every step up. It’s also set to BothWays just to see if it can work really. They are all simple links, turned off the SmartLinks. and their AreaClass is UNavArea_Jump.

I plan to take a look at the [FONT=Lucida Console]UNavigationComponent::GeneratePathTo sometime today as well :). I will attempt to see what I can do… but in the meantime, take a look at the image above to see if the setup like that would be appropriate for the NavLinks.

First apply the fixes I’ve mentioned. If it still doesn’t work I’ll need your project’s copy to be able to help you more.

Is it possible to implement jumping via blueprint? or is it going to be possible in the future? I just started getting my hands dirty with some of the behavior tree and ai stuff for my side scrolling shooter and it works great except my ai does not jump to places above him. He will “jump” or move to places below him, but nothing above.

Hi HypnoticShark,

There is a node in blueprints dedicated solely to jump! If you load up one of the template characters and look at the template character blueprints the node should be visible there. Have a great day!

I’m still trying to work on the Jump Navigation. slowly but surely getting it figured out. I will keep this thread up to date when I get this figured out. I still greatly appreciate this help so far :).

Currently it’s not possible to bake jumping information into a navmesh using blueprints alone. However it seems to be a popular request often enough to make it happen. In practice all that has to be done is to expose [FONT=Lucida Console]UNavArea::AreaFlags to BP, but we need to figure out a better way to expose it than simply exposing an [FONT=Lucida Console]uint16 value (it’s not really readable on its as such).

Did you get it working? I’m stuck with the (AreaFlags & JumpFlag) if statement always returning 0. The TestNavigationActors picks it up fine. My AI however, doesn’t.
My AI also just walks off the navmesh. I’m using MoveTo in a Behaviour Tree.

I’m working on a little tutorial on how to set this up. Give me some time to wrap it up, but here’s a basic C++ project that does that. Note that it has been build with master branch of UE4 so I’m not making any guaranties regarding compatibility with UE4 branches.

I’ve put my tutorial online. You can find it here. Feedback welcomed!

Hi MieszkoZ, thanks for putting up the tutorial. I followed it and am having 1 problem.

Edit: Closing the Editor and rerunning a couple times and it started working, I’ve noticed that it is inconsistent when changes come into the Editor. I’ll leave my initial comment.

The PathFollowing component is not being used, it doesn’t hit breakpoints in it. Here is where I set it, and the debug int breakpoint does hit.

Is the string important? TEXT(“PathFollowingComponent”), I tried changing this to see if it would change when I look in the Blueprint from the controller, but i think it is the default PathFollowingComponent.

ACatAIController::ACatAIController(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP.SetDefaultSubobjectClass<UJumpPathFollowingComponent>(TEXT("PathFollowingComponent")))
    int debug = 0;

I am in version 4.4.1 from the launcher.

Rama’s AI Jumping Videos

Hi everyone!

Here are a few videos I have of my AI jumping code, including a new one I’ve just uploaded!

I explain my methodology below

**AI Jumping To Reach Specific Goal Across Nav Mesh Gaps**

In this video I am showing how my C++ AI code is helping my AI units to get across gaps in nav mesh / different nav mesh sections to reach a specific goal!

My C++ code is enabling the AI to reach places they could never reach without some carefully calculated jumps!

**In all of my videos all jumps are dynamically calculated**, I am not using navlinks of any kind!

The only setup I did was to place the navigation mesh volume, the rest is done by me in C++ !

I use [Navigation Mesh Point Projection]( to keep the cost of all my AI analysis very low :)

Taking Jumping Shortcuts

AI taking shortcuts along known and good paths to shorten the journey!

In the above video, the AI has a good path to follow, and does not need to use jumping, but I do some nav point project calculations to determine when and where there are good jumping shortcuts that can be used!

See video for details! :slight_smile:

**My Methodology**

I actually created my own PathFollowingComponent subclass! 

Then I use a custom Controller, extending AIController,

and I overrode **InitNavigationControl()** to use my custom component!

**That's all there was too it!**

Now inside of:

**FollowPathSegment(float DeltaTime)**

the tick function of PathFollowingComponents, 

I perform all my custom logic!

Enjoy the videos!


Oh wow this thread!!! I tried out what MieszkoZ did for a tutorial and it worked great!!! just had to change Path->PathNodes] to Path->GetPathNodes()]

Rama, That is awesome!!! I wish to know thisssssssssss