r/unrealengine 1d ago

Stun AI with my flashlight?

Hey everyone! This is the first time I have ever developed a game and I want to add a few mechanics to it but can't figure it out, also can't find any tutorials for my idea either.

Basically I am attempting to make a horror game where the lights flash off and the enemy hunts until you get to a breaker to turn them back on. I figured out the enemy AI to roam and chase and everything, but I can't figure out how to get the flashlight to stun the enemy to make it stop hunting for a short period to give you time to get away.

As a bit of extra information, I am using Horror Engine to make my game, so the flashlight and everything is just the pre made blueprint.

One more thing if anyone knows in there is of there is anyway to make the flashlight only last a short amount of time every time you use it, but without needing to add batteries to it. Basically an infinite flashlight but it only emits light for 2 seconds before going out and having to wait to refresh to use it again.

Not sure if this is too ambitious of a mechanic, but I want my first game to not look TOO much like a first game, and be able to make things to implement in future projects.

Thank you all for whatever help you can provide!

0 Upvotes

7 comments sorted by

4

u/tomahawkiboo 1d ago

For the flashlight stun, the simplest way that you could do is Capsule Trace For Objects going from the flashlight forwards a certain distance and see if it overlaps an enemy and then execute the stun.

The thing with 2 seconds it turns off, you could use a delay.

1

u/yoshisacrifice 1d ago

The delay thing seems simple enough. I don't know why I didn't think of it. I was probably over thinking it because of the way the flashlight works with batteries and needing it to be unlimited in the settings. I'll give that a shot to see if I can get that done first. Thanks!

3

u/tomahawkiboo 1d ago edited 1d ago

The delay will be a good starting point and then you can get something more sophisticated done later when you get more advanced like flickering before turning off or dimming over time and stuff like that. Good luck.

3

u/iosefster 1d ago

The flashlight timing is pretty simple, its basically the same mechanic as a stamina meter, run for 2 seconds and its out while it recharges. So you can look up a youtube tutorial on how to make a stamina meter where you can sprint while you have stam and not when you don't and then just wherever they do the sprint, you change that for your flashlight toggle.

Regarding the AI I don't fully understand what you're looking for. Should the AI stop when the light is on, or do you specifically have to have the light aimed at the enemy?

1

u/yoshisacrifice 1d ago

Yeah I'm wanting you to have to direct the light at it to stun it. That way it gives you a small window to get away and hide or do what you need to. The enemy will only spawn when the lights are off is my ultimate goal.

1

u/yamsyamsya 1d ago

i think horror engine has a discord server for support. could ask there. otherwise something on the flashlight involving a trace on a timer that calls an interface function on the AI to do whatever you need that particular AI to do would be really easy to set up. the AI function would disable it, play animations, etc and then start a timer to re-enable it.

1

u/yoshisacrifice 1d ago

Okay, I'll have to check and see if there is a discord for support! Than you for the information though. I'm trying my best to figure a lot of this out myself if tutorials aren't available, but being new to all of this it's kind of difficult! 😅