AI is walking very weird in Standalone game (Editor runs fine)

Since I have no idea how to explain this bug, I just took a video:

I did not have this issue in 4.6 but I have never tried opening a standalone game with 4.7.1 or 4.7.2 or and at the moment I use 4.7.4 from github from yesterday (11 commits after 4.7.3). I first had this issue with 4.7.3 but since I heard there would be a critical AI fix in 4.7.4 is hoped it would fix this.

That my structs and enums don’t work in a standalone game is a known issue as far as I know.

By the way, any idea why my compile times are so horribly high?

Looks like a bunch of issues, one being related to Animation, the other to some game-specific AI logic. Have you tried recording a vislog and looking at what it says? You summon the UI by running vislog command. Just press record and do your thing. There should be plenty of useful information about code AI things that are going on under the hood. Give it a try.

Cheers,

–mieszko

If I enable vislog in the standalone game and click on the red start button, nothing happens. I get the red “Vislog Recording active” message on the top right, but I don’t see the different AIs in the Visual Logger as if I would start the vislog from the game in the Editor.
That the AIs don’t start moving to the buildings is most probably due to the missing struct and enum values, so for this answerhub post I only care about the very strange movement of the AIs.

Please help :slight_smile:

Is there any reason why you don’t answer further on this? Its clearly a bug!

Well, for starters, I was out of office :stuck_out_tongue:

Regarding the issue you experience you really don’t share a lot of detail and I don’t have enough information to figure out what’s wrong. I would suggest, first of all, removing all the BP compilation issues to make sure this is not BP-related issue. Once that’s done and AI still has movement issues, it would be ideal if you could chop the project down to a reasonable size and send it our way. Feel free to send it directly to mieszko.zielinski@epicgames.com and just post information here that you did.

Cheers,

–mieszko

I would really like to follow your suggestion to remove all the BP compilation issues, but that’s just a bug I cannot change, your programmers are the only ones who can fix this :stuck_out_tongue: And the issue you see in the video is just that UE4 thinks that BPs need to be recompiled even if they were not changed, but that’s just due to cyclical dependency I guess. Someone from Epic said we will have to wait for 4.9 to get this really fixed. It’s only “cosmetically” to it’s not really important.

Ok, I have “chopped my project down” to a very small size. Actually, I deleted everything except the AIs. And I also found what’s causing the problem. It’s almost funny.

So, this is my behaviour tree:

http://puu.sh/h7ZsE/86ce5dba76.png

And if I delete the selector on the left, it does work, otherwise I get the bug. I don’t know whether my eyes are bad, but I can’t see any wire going to the selector, so it should not matter, right? And even more funny, that’s the service:

http://puu.sh/h7Zyf/a5b35efe31.png

Yes, again, not connected to anything. But if I delete these 4 nodes in the service, the bug is also gone.

I will send you a download link to the project.

Thanks for the repro-project, it allowed me to nail the issue pretty easily.

So the reason AI is walking funky in the Standalone Mode is that you have runtime navmesh generation enabled, and the character is marked as navmesh-generation-affecting (via Can Affect Navigation Generation flag). So as AI is moving it’s invalidating navmesh around it, which results in invalidating the navigation path it’s following. If you enabled navmesh debug drawing (the show navigation console command) you’d see that instantly.

Now the real bug underneath is that your characters’ collision setup is not read in properly in standalone games! It all works great, regardless of the Can Affect Navigation Generation flag, in PIE because your characters are set up to ignore Pawn and Vehicle collision channels. The root issue here is that this setup is not getting applied to pawn in the standalone game. Of course I’m reporting that as a serious issue!

It seems you don’t need navmesh-affecting pawns, so I suggest you cleared the Can Affect Navigation Generation flag on your characters.

You might also consider using one of physics collision presets rather than a custom setup, since I feel that’s where that collision setup bug resides.

Cheers,

–mieszko

Thanks a lot!

I had affect navmesh generation enabled because I want my AIs to set a very high navigation cost to where they are, so that other AI will try to navigate around them and if it’s not possible, just run through them. So they will avoid each other, but only if there is another not too long path to the target.
I have not cared about this much since there was some bug with the nav modifier component so it does not move on runtime. If I remember correctly I also had a bug report about this on the answerhub.

A general question, where should I set stuff like “Can Ever affect Navigation”? On the Class defaults, on the CapsuleComponent or on the Mesh?

I have very often enabled navmesh drawing in the editor, but I thought the only way to do this is pressing P, so I did not know this is also possible in the standalone game.

The collision is set to something custom because I want my AIs to collide with almost anything, but being able to walk through other AIs. And there is no preset for this.

Do you have something like these UE-xxxxx numbers for the bug?

A general question, where should I set stuff like “Can Ever affect Navigation”? On the Class defaults, on the CapsuleComponent or on the Mesh?

For characters you need to set a different flag in class’ defaults, the Can Affect Navigation Generation.

One thing I highly recommend while making characters affect navigation is to do that only when characters are static, meaning when AI character stops enable navmesh affecting and when character starts moving disable it. Otherwise you’ll end up with any one AI moving invalidating all navigation paths going through the same tiles the said AI is moving through.

The collision issue has been filed as UE-13662.

Thanks!

My Characters affect the navmesh because like I said in the last post, I want my AIs to avoid each other but only if there is another not much longer path, otherwise just run through each other. So e.g. if the alternative path is more than 50% longer than just running through another AI, it will run through the other AI. Is there any other way to achieve this?

Nope, it’s pretty custom and we don’t have anything supporting exactly what you need out of the box. Our Detour Crowds integration is your best option in my opinion.