I’ve encountered a really weird bug, and things are a bit too complicated for me to find the root cause.
I’ve finished the UnrealCourse, with some minor tweaks. My repository is available at https://github.com/MitchReidNZ/ProvingGrounds
My problem is that when I shoot, which calls AActor::MakeNoise to broadcast the noise to the AI, my movement speed suddenly plummets and I can barely walk around the map. Jumping happens in normal speed, and the AI in the level can all move at normal speed - it only affects my character speed.
I’ve got a single character which holds a Gun actor.
The gun actor calls AActor::MakeNoise when it fires, so that I can notify the AI in the level of my character shooting.
The AI controller has an AIPerceptionComponent which registers for both Sight and Hearing events. When it detects something, I update a blackboard key with the actor it detected.
My behaviour tree then calls MoveTo to walk toward the actor.
It’s at this point that my character suddenly starts moving really slowly.
I’ve narrowed it down to this after looking at a number of things:
- Gun.cpp:line 66 calls MakeNoise. If I comment it out the AI can’t hear me, but I don’t get the character slowdown.
- Leaving MakeNoise uncommented in the gun, and removing the hearing component from /Dynamic/Character/AI/NPC_AI_BP means my AI will chase me on sight, but can’t hear me. And I don’t get the character slowdown.
By checking these two points, I’m confident that the problem comes from my AI Perception setting the target in the behaviour tree (/Dynamic/Character/AI/BasicGuard)
I then went through the behaviour tree disconnecting nodes until I could find whats causing the problem, and it appears to only happen when I run a MoveTo node.
To verify this, I’ve simplified everything else out of the behaviour tree, to get the following screenshot:
If I break the link to the MoveTo node, I can shoot and run around to my hearts content. But if I have the link to the MoveTo node, as per the screenshot, I suddenly move really slowly as soon as I shoot.
Does anyone have any suggestion on what I should look at next to try and solve this?