I have been looking around quite a lot to try and find an answer to this question, but as I am fairly new to using UE4 and still not great at c++ I was hoping someone could point me in the right direction.
What I want to be able to do is to modify the range of senses during runtime for my AI. This is to be able to make the range smaller if the AI is chasing after a sound or to make the sight radius bigger if the player is using a flashlight.
After finding this link and messing around in the BP editor I assume that the functionality was never added to blueprints, and as such I need to be able to do it using c++, but I am not sure how to use the provided code to expose the sense range to the BP editor.
I also have this same question. There is an old response that has some code on it, but for the life of me I could not get it to work. Maybe I just don’t understand the AI Perception well enough.
That’s the link I found that apparently solved the problem for this person. I personally couldn’t implement it, but my coding skills are still at the beginner level so I don’t really even know where you would add that to make it work.
I took the code from v.s.'s post and split it into two functions, so that I can easily add the same thing for hearing or other senses. Something that may need explanation is how the LoseSightRadius value gets automatically set, it takes the difference of the current SightRadius from LoseSightRadius and adds that to NewSightRadius. In other words it keeps the same distance between SightRadius and LoseSightRadius and uses that with your NewSightRadius.
Any ideas how to do this without having to pass an AIController, I am using the perception system on my player character to work out when NPC’s are in range, so I need a blueprint that takes the perception component and not the AIController - any ideas?
Does anyone still have the files or the entire code for this? I can’t seem to get this to work and I don’t know if it’s UE4.26 or my own incompetence in c++