x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How do I spawn a Nav Modifier within the Editor in C++?

Hi all,

I want to create a tool that allows me to string together nav modifiers on a map in the editor. Think of the spline component but I'm just making rectangular nav modifiers that touch tip to tail based of the points you've created. I've already set up a NavRoad component and NavRoad component visualizer, but I'm not sure how to actually spawn an object in the editor that can affect the nav mesh with a given custom UNavArea. Does anyone know how I can do this?

I've read that you can't just spawn regular nav modifiers so I created my own class that I want to spawn, but I'm not sure what I should derive from for them to affect the nav mesh.

This is all done in C++ and any help would be really appreciated!!

Product Version: UE 4.21
Tags:
more ▼

asked Jan 08 '19 at 12:22 AM in C++ Programming

avatar image

LDOGLONDON
75 5 5 8

avatar image LDOGLONDON Jan 08 '19 at 06:36 PM

Right now, I'm deriving from a UBoxComponent and overriding the GetNavigationData() and GetNavigationBounds() functions that come from the INavRelevantInterface. Also in my constructor i'm setting bNavigationRelevant and bCanEverAffectNavigation to true. Also I'm calling UpdateComponentData(*this) in PostEditUndo and PostEditChangeProperty. I am also making sure, in the constructor, to set what AreaClasss i want to use for the box. But the nav mesh doesn't change or detect the box component.

Mieszko said to try to follow how the nav modifier does things, here: https://answers.unrealengine.com/questions/498659/how-to-spawn-a-navmodifiervolume-in-c.html.

I got this to work for an actor that I gave the INavRelevantInterface, but not for a component. Also just in case you were wondering UBoxComponent does have that interface.

So still stuck. Does anyone know about UNavModifierComponent or if that is useful to me? Or if I'm missing something with the UBoxComponent?

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

So I was able to do this by having a base AActor class that holds a USceneComponent, which deals with spawning all the UBoxComponents. I have the USceneComponent so I can attach a component visualizer attached to the hole thing. The AActor also holds a UNavModfierComponent which basically looks at all the volumes connected to the AActor (the UBoxComponents) and modifies the nav mesh based on them.

Also something to note is that when you create the UBoxComponents within the editor, in order to make them visible and actually connected to the AActors component list, you have to call RegisterComponent() on the newly created UBoxComponent.

If you have any questions feel free to comment and ask

more ▼

answered Jan 10 '19 at 06:42 PM

avatar image

LDOGLONDON
75 5 5 8

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question