I have a flashlight (spotlight) working with my FPS character. I’ve setup a BP where the player can turn on/off the flashlight. What I’d like to know how to do now is have an actor trigger an event when they enter the flashlight beam.
I’ve read that traces might work, but I’m not sure how to get started, considering it’s not a line I’m looking for.
Hello MediaMike.
If you do not want to use mulitple ray traces you can create a custom collider in your 3D program. make it the shape of the flash light beam and set the collision preset as trigger. Then use the OnComponentBeginOverlap to check what is in the trigger area.
But if you want to use ray traces you can make 5 ray traces and put 4 in an angle and one in the center.
I was able to get a single line trace working in the center of the flashlight. Do I just repeat the process to create the other 4? How do I got about getting the same angle that the spotlight cone has? How do I have the multiple line traces trigger the same action?
Sorry for all the questions, I’m still a bit of a noob.
You can use the vector forward node from the spotlight object to create the traces and multiply it with an value for the distance, add alittle to the x coordinate(or another one) to get an angle.
And repeat for all traces. The reason for the middle one is if there is something in the middle of the flash light and the 4 outside rays do not hit it because it is too small you still get data back.
Goodluck