When Player see Enemy inside camera
Dears I want you support please cause i took 3 days to figure out how i achieve it. When player see enemy inside his camera it will play sound like ( impact sound effect ). I it's work with single line trace, but this is not what i want . for example the enemy appear behind player, when player rotate his camera to see what behind him and see the enemy it will play sound effect .
I need camera full range not with single line trace .
Please help me to achieve this
Here screen shot with single line trace
I went ahead and made a quick example of one way you could use a single line trace to determine if you can see an object. This example should give you a starting point. I hope that this information helps.
In short this uses a single line trace to form a grid that's size is determined by the bound of the object you are looking for. This is done by preforming a line trace starting the top of your screen to the top of the object and lerping to a line trace from the bottom of your screen to the bottom of the object. Each time this line trace completes a lerp it will move from side to side one step at a time and perform the vertical sweep again.
The second part of this blueprint checks to see if the object is roughly within the frustum of the camera. It does this by converting the location of the object to screen space and then it checks to see if that screen space location is on screen.
The final check looks to see if the object is within the viewport and if one of the line traces have hit the object that you are looking for. If this returns true then the object can be seen.
Make it a great day
answered Dec 02 '15 at 09:42 PM
Rudy Q ♦♦ STAFF
I'm not sure how to do this in blueprint. I'm sure you can get onscreen or rendered actors, but I dont think theres a node for it.
the easiest way would be to make a giant collision box in front of the camera thats attached to an element that moves with the view. Create an Onbegin Overlap event, drag out "get all overlapping actors", if it == the actor in question then do once -> play the sound. Might work in BP. Try it out.
answered Nov 30 '15 at 07:09 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here