Jump to content

Navigation API questions


thehankinator
 Share

Recommended Posts

Hey Guys, I have been working on implementing my own AI scripts that better fit my use case. I've got things working just about the way I like it but I have some problems with entities getting stuck and it's really highlighted that I don't fully understand the details of Follow, and SetInput.

 

Follow

My stuggle with this function is that after I've set my entity to follow the player, sometimes it just stops after moving for no less than 4 or 5 seconds. Not sure if it is all in my head but it almost seems like if one entity is stuck, more than of them get stuck at the same time. There really isn't many obstructions on my map, it's a flat surface with about 6-8 blocks to act as walls and Nav Mesh updated. I think my question here is once a Follow command has been issued and the return value is true(meaning success), what sort of things can break the course(besides Stop)? Is there some way to check if the course is still valid? How expensive in computer terms is this function? If I call Follow multiple times, do I need to call Stop first?

 

SetInput

I am not sure of what situations SetInput is designed to be used when utilizing Follow. It seems like my NPCs less often face the player if I remove SetInput but I am not convinced I am calling this function at the right times as it seems like they run toward walls momentarily if I use this function.

 

I know a lot of the example I gave here are wishy washy but so is the behavior I see, 90% of the time everything works as expected. Then every now and then there is some idiot running at a wall. Any insight into the inner workings of these functions would be awesome!

Link to comment
Share on other sites

This works ok for me

 

 

barb.model->Point(jane.model, 2, Time::GetSpeed()*0.1);

barb.pivot->Follow(player, 1.8, 4);;

 

I have not used SetInput with enemy characters, only the main character.

The enemies follow main character when at a specified distance. o

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

This works ok for me

 

 

barb.model->Point(jane.model, 2, Time::GetSpeed()*0.1);

barb.pivot->Follow(player, 1.8, 4);;

 

I have not used SetInput with enemy characters, only the main character.

The enemies follow main character when at a specified distance. o

For some reason things are still getting stuck. I see you are using a pivot, does it have Character Controller physics?

 

The documentation says

When an entity uses character physics, the physics will control the object's rotation, and calls to Entity::SetRotation() and similar functions will have no effect.

Seems like Point is similar to SetRotation (documentation does not provide a full list of functions that will not work with character physics). Perhaps character physics is not good for navigation? Using the Crawler and MonsterAI.lua as a working example says otherwise.

 

You do have "Nav obstacle" checked for your blocks?

 

This then includes them in the Nav mesh otherwise the character will try and walk thru them.

Yes, the nav mesh appears correct. Shows the mesh going around but not through the blocks.

Link to comment
Share on other sites

I've been playing with it a bit more, if I remove SetInput()/Point() and call Stop() and Follow() continously it doesn't look like they are getting stuck (or stuck as often anyway). There really should be some way to figure out if the course Follow() plotted previously has failed so that it can be replotted. Or is it best practice to continuously plot the course with Follow()? Without some way of profiling Follow() it would seem like NPCs continuously calling Stop()/Follow() is a bad idea for performance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...