Rightio, basic setting is a pretty much pitch-black maze, with some environmental lights here and there (all flicker-y and spoopy) and the character with a flashlight. So what I hope I can do is make the monster “see” the flashlight’s light and go towards it if it sees it, and care about the environmental lights way less. The thing is, I have no idea how to make the monster “see” the flashlight’s light, and since the light is mobile and stuff, I think little “cheats” might not work. Any help?
Well, I’m just spitballing off the top of my head here at the moment, but my first thought, would be to run a check (regardless of if the AI can actually see the Player I.E. if there is something in the way or not), to see if the light is turned on. (easily done by a boolean variable on the Player). I’d then have a second check if that was true, (maybe a line trace) to see if the AI can actually see the player or if a wall or something is in the way. You could also give the AI a “cone of vision” by making a volume and check for the light if the player enters it.
Yeah I think possibly moving away from the monster detecting the lightsource, and instead just checking if the monster can has line of sight of the player.
Although you may run in to problems, if for example you want the monster not to detect the player if you did have your flashlight on but it was not directed at the monster.
pbarnhardt’s suggestion seems pretty solid, but another option is to not use line tracing but use the in-built ‘pawn sensing’ nodes and set up the monsters ‘cone of vision’ through that component. Then if the player is within the cone of vision and the flashlight is on (checked via boolean) then detect player.
There may be various different ways to achieve this, but one question is do you want your monster to be able to detect the player even if the player is not looking at the monster with the flashlight.
If you still want to do the light source you can spawn a collision volume in the rough size and shape of the light from player to what it hits. This could have its own collision channel. Then have the ai check for that. You would have to either attach and adjust it with the light or spawn and destroy the volume. Not sure if this helps I just thought I would through my own 2cents in. It is also probably a rambling post.
I agree with Imonin: perform a trace from the flashlight into whatever it’s supposed to hit in the center and have your monsters sense that. You could also place a volume at wherever the flashlight is hitting and when the monster overlaps with it they can “spot” the player.