Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

alt text

Product Version: UE 4.9
untitled.png (201.8 kB)
more ▼

asked Nov 28 '15 at 01:11 PM in Blueprint Scripting

avatar image

30 8 11 15

avatar image TakeTimeGames Nov 29 '15 at 05:39 AM

Remainder Please help

avatar image TakeTimeGames Nov 30 '15 at 05:37 AM

Anyone , need help Please still can't figure it out

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hello TakeTimeGames,

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.

alt text

Make it a great day

more ▼

answered Dec 02 '15 at 09:42 PM

avatar image

Rudy Q ♦♦ STAFF
47.5k 545 132 522

avatar image thankstipscom Dec 03 '15 at 05:26 AM

Wow, in BP I woulda when with an easier probably less reliable approach until I was production ready and then did it some better way,but I'm gonna save this image for future use. thx

avatar image TakeTimeGames Dec 07 '15 at 07:17 PM

Can you please mr.Rudy send me a copy of your blueprint cause you know it's very complicated , i got confused :(

avatar image Rudy Q ♦♦ STAFF Dec 07 '15 at 08:23 PM

Hello TakeTimeGames,

I have recreated the blueprint above in a blank project. I hope that this helps. I have provided the project below. Please remember that this is meant as an example to point you in the correct direction.

link text

Make it a great day

blankexample.zip (881.0 kB)
avatar image TakeTimeGames Dec 12 '15 at 06:46 PM

Hi Rudy : your blueorunt it's working with my idea and thank you for that , but i have problem if actor in world it's work , but how about spawn actor? I mean if the actor not in level , it will be drop frame , cause my actor not in the level but if i spawn actor it will be work how avoid dropframe if my actor not spawn

This is Video Example https://youtu.be/dik24g4-1j8

Thank you for supporting !!

avatar image Rudy Q ♦♦ STAFF Dec 14 '15 at 03:21 PM

If you are having an issue with the with the actor not being in the level, I would suggest not starting the blueprint on begin play and instead having it start the loop when the actor is spawned and stop the loop if the actor is removed.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Nov 30 '15 at 07:09 AM

avatar image

654 38 37 70

avatar image TakeTimeGames Nov 30 '15 at 09:01 AM

Thanks for the answer , I'm thinking also this idea and i think it will work 100% but this idea will not work for other thing , for example : If the wall between player and enemy , if i put your idea the sound will play cause the enemy will overlapping What i need , i need hit actor only camera view this will be work not single line trace , but how to do this ? I hope to get the answer.

avatar image thankstipscom Nov 30 '15 at 09:27 AM

I understand.

You could still use the overlap, but when it overlaps the actor just before playing the sound, do a single line trace to the vector of the actor that gets overlapped if it hits the actor make sound. If it doesnt.. it must be behind a wall or obstruction.

otherwise maybe a large sphere trace on event tick

avatar image TakeTimeGames Nov 30 '15 at 10:56 AM

OK I will try , and i will be back to give you result , thanks

avatar image Enlo Nov 30 '15 at 11:11 AM

I would have suggested the same as @thankstipscom . You could simply do an LineTrace whenever you get a overlap to check if you can actually see the object.

Then I stumbled over this in the docs, I think it's exactly what you need: Shape Traces

avatar image TakeTimeGames Dec 02 '15 at 06:41 PM

Hi @thankstipscom and @Enlo I finally manged how to make box line trace and finally detect enemy

alt text

, but there is one problem , i tried many way how can't detect enemy if player see wall . for example there is wall between enemy and player , i want to block wall and can't box trace go through it

Here what i'm looking for :

alt text

untitled.png (225.1 kB)
un2titled.png (17.4 kB)
avatar image Enlo Dec 03 '15 at 09:28 AM

Hm, Sounds like you need to do a line trace with the Trace Channel = Visibilty set.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question