Thats all working now, thanks a bunch for your time! i had a final question (for now)
Is the complete line of sight visualization included in this? if so, why does it seem that changing the settings doesn’t change the arc or length of the visual cone?
Yes, Line of Sight Visualization was completely integrated into the toolkit in one of the updates. However, since the toolkit has actual AI, the vision parameters are customized through its AI Perception component as shown here:
Just make sure that you are editing these values within the blueprint editor and not from the level editor. Last I checked, components in Unreal have this limitation where even if we expose these values to the editor for easy customization, they don’t reflect the changes until the game starts.
Actually! one more thing, would it be at all possible to make the vision cone move left or right when the guards head*** does so? ive tried copying the rotation, attaching it to the head creating a dummy los vision actor and attaching to the character but none of those seem to work.
Well, the LoSVisualizer component relies on a couple of interface functions to retrieve information about its owning actor such as Vision Range, Forward Direction, etc.
I haven’t tried this myself, but I’d suggest opening up the RetrieveVisionParameters interface function in your patrol guard blueprint and attaching the forward vector for your character’s head (maybe using some bone socket) instead of the Actor Forward Vector that is used by default.
Il give that a try! yeah i noticed it used the data from vision stimulus and went so far to create custom a c++ class that attached the vision cone to the characters head bone.
Thought that would be a “quick” fix, but it sadly did not work.
Oh, I can assure you that this can be done in blueprints itself. Off the top of my head, it would require adding a new socket to the head bone in your character, then attaching the Visualization Mesh to this socket of the character mesh component at the start of the patrol guard construction script, and then making the changes mentioned in the solution above. That should most likely get it working.
here i am once again, been reading through all the tutorials and stuff, but i’m a bit confused at the aural perception, is the only value you can edit the hearing range of the guard?
What if i want footsteps to be more silent and only to be heard closer and a whistle to be louder and be able to be heard over a further distance?
Yes, that is actually possible. But unlike the hearing range which is defined within the AI perception component, the loudness (or rather how much a certain noise can be perceived outside the normal range) is defined as a property of the stimulus itself.
Within the BP_AISensoryManager blueprint, you can find a variable called InterestStimulusDataArray which is where different types of stimuli are defined. And it has a parameter named PerceptionRangeModifier (now I realize that it doesn’t convey the meaning as clearly as the term Loudness) which essentially acts as a multiplier to the AI’s default perception range.
For example, an Alarm Noise has this value set to 2.0, while the Whistle noise has it set to 1.0.
So let’s say your AI guard’s hearing range is 300 units. For the Alarm Noise, it will be perceived up to 600 units, while for a Whistle noise, it will just be heard up to the default range of 300 units. Similarly, you can set a value of say 0.5 for the footsteps so that it will have a reduced range of 150 units.
And thanks for pointing this out. I’ll add a separate tutorial this week going over the different attributes for setting up new stimuli.
Oh right, i forgot to mention, no idea if this is just myself, but i have this problem that within the motion perception area, the vision cone does not work?
The AI should identify the player as soon as it turns around. Does this happen when you’re using the default characters in a new project?
If the issue only happens with custom characters, it could be the vision trace being blocked by the AI mesh. Just make sure that in the AI blueprint, the collision settings for the mesh is set to ignore the AIVision trace channel.
For testing purposes, you can also set the Draw Debug Type to For Duration within the LineTraceEvaluation function in AI Perception component. This trace should ideally only be blocked by walls and other obstacles. So if it doesn’t reach the player character when you’re within the motion sensing region, then its getting blocked by the AI mesh/capsule most likely.
It was a problem with the new vision parameters, since i set the the trace to be shot from the head, it was overshooting the player when it was close thus not hitting it, changed the origin to the capsule but the end point the forward vector of the head bone and all working nicely now!
Also i modified a LOT but i got the effect i wanted now! added a timer that gets slower and faster how far you are from the target which is multiplied if the character is sneaking and sped up when sprinting!
(nothing special i just wanted to share what ive been working on)
That is actually pretty good progress. I’m working on a somewhat big update and hence why the 4.27 edition had been put on hold. I was hoping to include something like this and seeing it in action is a pretty good motivation to go ahead with it.
then added a timer based on the wait time delaying the set active target.
(though i don’t know if this is best way to do this, since a couple of things cause problems, mainly the alert meter keeps going when the time is being delayed, as you’re technically still in vision radius)
Thanks for sharing your solution. This is one of the two approaches we can go about implementing a delayed detection.
The other one is to have a small additional section in the left part of the Behavior Tree which deals specifically with what to do when the AI detects a target. It could have some condition that, only if completed, will let the AI start chasing or firing at the player. I’m going to try this approach and see how it goes.
Actually got this working a year or two later haha. Any ideas on creating smoother maybe more robust aiming? Seems the aiming is kinda of jittery on controller, maybe something with more sensitivity?
Hi Dresyn, I’ve only worked with mouse and keyboard in Unreal. So I’m at a loss with regards to controller settings, but by jittery do you mean it that doesn’t seem to be updating every frame? Or more like it’s lagging behind?