Download

NavLink and making AI jump?

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](https://forums.unrealengine.com/showthread.php?25410-Rama-s-Multi-Threaded-Dynamic-Pathing-System-Full-Physics-Support&p=129896&viewfull=1#post129896) to keep the cost of all my AI analysis very low :)



https://www.youtube.com/watch?v=0GX-1x-wACI


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!

Rama

http://share.gifyoutube.com/ZGQn5M.gif

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

jumping ai

I did the same tutorial but it doesn’t work. My ai is patrolling between target points and I placed one onto a platform which is only reachable by jumping.
My patroller doesn’t jump. I don’t know where I miss anything. My code is compilling well and I placed the navlink and set the area class to navarea_jump =(

MieszkoZ Your link is broken :frowning:

UE4 AI Wiki Tutorials

Dear Community,

I have these wikis on the subject of UE4 AI that should help out:

Custom AI Path Following Every Tick in UE4

UE4 AI, Using Nav Modifiers and Query Filters

AI Dodge Mechanic Using Rotate Vector Along Axis


**The Atomic Spatial Unit of the UE4 Navigation System**

Make sure to check out my C++ code how to get every Nav Poly in your level, which is the unit of the UE4 Navigation system that you can use to impement any kind of custom pathign you want!

**Get All Nav Polys C++ Code**
https://wiki.unrealengine.com/AI_Navigation_in_C%2B%2B,_Customize_Path_Following_Every_Tick#How_to_Get_All_UE4_Navigation_Polys

**Video Of Usage of Nav Polys**
I did individual Nav Poly calculations to implement my [multi-threaded AI Jump Pathing System (videos)](https://forums.unrealengine.com/showthread.php?25410-Rama-s-Multi-Threaded-Dynamic-Pathing-System-Full-Physics-Support&p=251216&viewfull=1#post251216).

Enjoy!

:)

Rama

Hi all, I hope this is the best place to reignite some discussion on this.

I have implemented this successfully using a combination of the thread and the old tutorials by Mieszkoz (use the wayback machine).

My problem is wanting the ability for someone to be able to select the AreaFlags to be set via a blueprint.

My steps are:

  • create a navlinkproxy blueprint
  • have a public blueprint variable (see screenshot) that references the enum in of my different types of jumps (jump, jump and climb etc)
  • when I start the application, it will look at the variable, and run a public method on my navarealink_jump class, which sets the AreaFlags.

The only problem I have is referencing the navlink_jump class methods. They are public but are within the class that is set on the blueprint parent navlinkproxy simplelink…as we have done here.

I hope I have explained it well, here is my code and a screenshot of where I am stuck.

NavArea_Jump.h




#pragma once

#include "AI/Navigation/NavAreas/NavArea.h"
#include "NavArea_Jump.generated.h"


UENUM()
namespace ENavAreaFlag
{
	enum Type
	{
		Default,
		Jump,
		JumpClimb
	};
}

UENUM(BlueprintType)
enum class JumpableNavAreaFlags : uint8
{
	Default	UMETA(DisplayName = "Default"),
	Jump		UMETA(DisplayName = "Jump"),
	JumpClimb	UMETA(DisplayName = "Jump and Climb")
};

namespace FNavAreaHelper
{
	FORCEINLINE bool IsSet(uint16 Flags, ENavAreaFlag::Type Bit) { return (Flags & (1 << Bit)) != 0; }
	FORCEINLINE void Set(uint16& Flags, ENavAreaFlag::Type Bit) { Flags |= (1 << Bit); }
	FORCEINLINE bool IsNavLink(const FNavPathPoint& PathVert) { return (FNavMeshNodeFlags(PathVert.Flags).PathFlags & RECAST_STRAIGHTPATH_OFFMESH_CONNECTION) != 0; }
	FORCEINLINE bool HasJumpFlag(const FNavPathPoint& PathVert) { return IsSet(FNavMeshNodeFlags(PathVert.Flags).AreaFlags, ENavAreaFlag::Jump); }
	FORCEINLINE bool HasJumpAndClimbFlag(const FNavPathPoint& PathVert) { return IsSet(FNavMeshNodeFlags(PathVert.Flags).AreaFlags, ENavAreaFlag::JumpClimb); }
}

UCLASS()
class SLUMCITY_API UNavArea_Jump : public UNavArea
{
	GENERATED_BODY()

public:
	UNavArea_Jump(const FObjectInitializer& ObjectInitializer);

	// setup our jump types via blueprint
	UFUNCTION(BlueprintCallable, Category="Jump Types")
	void SetAsJumpType();

	UFUNCTION(BlueprintCallable, Category = "Jump Types")
	void SetAsJumpAndClimbType();
};



NavArea_Jump.cpp




#include "SlumCity.h"
#include "NavArea_Jump.h"

UNavArea_Jump::UNavArea_Jump(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{}

void UNavArea_Jump::SetAsJumpType()
{
	FNavAreaHelper::Set(AreaFlags, ENavAreaFlag::Jump);
}

void UNavArea_Jump::SetAsJumpAndClimbType()
{
	FNavAreaHelper::Set(AreaFlags, ENavAreaFlag::JumpClimb);
}



The blueprint I created was instanced from the navlinkproxy. I feel like those public methods that set the AreaFlags should be in that NavArea_Jump class, but it also feels a little coupled.
In saying that is there a nicer way to do this?

db7953ec49d110bf62ec5f0f0ddfe22c15ae4971.jpeg

I feel it should be pretty easy but I think the blueprint access with navlinkproxy is limited.
The alternative would be to approach it microservice style - have a nav area class for each action I want such as NavArea_Jump, NavArea_JumpAndClimb etc…

To be honest, the alternative feels like a better solution, but I figured I should ask the experts.

cheers

Is there any way to get an AI to follow a player character and jump with it using NavMesh? But only in Blueprints, C++ doesn;t work in my workplace.

The link is broken. Can you fix it?

Thanks in advance! :slight_smile:

Nevermind! Found it here: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums1-_Making_AI_Jump_as_a_Part_of_Path_Following

Thanks again! :slight_smile:

Yeah, my original blog is off line, but all my posts can be found on wiki.unrealengine.com

Forgot to reply but it was really easy by following the steps you provided. :slight_smile:

However, I have another question: suppose that you have several ladders with different heights and the idea is the NPC to climb those. Do you think that special navigation areas will also fit?

Thanks in advance! :slight_smile:

Cheers!

For ladders I’d use smart nav links :smiley:

Hey guys, please, I need help, I’m trying to make this tutorial work, but I’m having problem with the “FNavMeshNodeFlags”… It doesn’t seem to find that identifier… I’m on 4.12.5, what is missing/changed?

I found them by adding #include “AI/Navigation/RecastNavMesh.h” at the top of the headerfile

Hey!

I did this without C++, Nav Links and so on.

Just modified some properties on the Recast-Navmesh actor.

Cheers!

That’s great! New properties added from the Recast-Navmesh actor since last year???

For anyone who looked this up thats in 2020 and want a simple easy none c++ way here is what i did and it works perfectly, using the ue4 version 4.24 right click your proxy and look down to were it says add event, you gonna click that and its gonna open up a list of events that might be related to what you are looking for, how ever the one we are looking for is the very first one Onsmartlink reached, this will give you the capability to tell the server once your ai reaches the point so on so forth Screenshot-19_LI.jpgyou wann make sure bothways is unless other wise and a must is to keep the smart Link is relevant this is the whole point of what we are doing. Finally on to the results click on the Onsmartlink reached event it should open a level blueprint, you will now drag of the white wire and type cast to… what ever ai you are using if its more then one then you could use a sequence, then you are going to add a delay of 0.2 this creates a perfect last minute jump because if your ai is roaming it may generate another destination before jump therefore jumping to its generated destination instead of your platform, next add you jump action drag off the wire from delay and type jump, and your all set you have a simple ai jump from platform to platform its after following this it should look like this

Hope this helped