Announcement

Collapse
No announcement yet.

Possible to restrict character to NavMesh?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Possible to restrict character to NavMesh?

    Hey guys.

    I have automated AI Pawns that correctly use a NavMesh to seek and hunt the player. Cool!

    But the character (pretty much the default ThirdPersonCharacter blueprint) is player-controlled, and I also want him to stay on the NavMesh. Currently, the character seems to move around the world exclusively via Add Movement Input and collision with world geometry. How can I lock the character to the NavMesh and not allow him to walk off?

    I tried turning off "walk off ledges", but this seems to only apply to height related cases. I want to straight up block him from moving off, ever. Is this possible? Or do I have to roll my own solution and give up a lot of the nice functionality in Character Movement?

    #2
    Without looking too much into this, my advice would be to do something like this:

    You are already using the Character as your base pawn. Character has a CharacterMovementComponent. You can bind a function to the MovementComponent's OnMovementUpdated event and this will give you his current position every tick. From here you may be able to take his current position and project it to the NavMesh somehow and if it is not on the NavMesh then call the MovementComponent's StopMovementImmediately() function. You should look at the UNavigationSystem::ProjectPointToNavigation function to see if this can help you determine if his location is or is not on the nav mesh. I am not sure if there is a BP equivalent.

    Good Luck,
    Jake

    Comment


      #3
      Sounds like a good plan, ants. Thanks!

      Comment

      Working...
      X