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 (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 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 method on my navarealink_jump class, which sets the AreaFlags.
The only problem I have is referencing the navlink_jump class methods. They are 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 : UNavArea
{
GENERATED_BODY()
:
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 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?
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