x

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"

Is there a way to make a "Look at" function to trigger events?

For example, if I look at a box, it should turn red, play a sound, or cause something else to trigger. I'm making a horror game involving ghosts and I would love to add in things like "shadow in the corner of your eye" gameplay where as soon as you turn to look, the object should disappear, or when you see a ghost a gasp sound should be played. Can anyone help?

Product Version: Not Selected
Tags:
more ▼

asked Feb 23 '15 at 10:46 PM in Blueprint Scripting

avatar image

GBicer
13 5 7 8

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

1 answer: sort voted first

There are a couple of different ways to model line-of-sight, which is essentially what you're doing. You could use a single sphere trace from the centre of the player camera in the direction of the camera's forward vector. The sphere would essentially represent the area of the camera's field of view which is not in the periphery. You'd probably need to set up a specific trace channel for this so that normal geometry doesn't partially occlude your trace.

Another way I've seen this faked is to parent an invisible cone to the camera's origin, pointing the base of the cone along the forward vector, and you can trigger effects if the invisible cone collides with your ghostly objects.

Lastly, you could use the dot product like this:

alt text

Evidently this is more mathematically oriented, and doesn't take into account if some other object hides the ghost entirely, but you could combine it with the sphere trace, allowing the sphere to collide against other geometry, to handle that.

lookat.png (221.6 kB)
more ▼

answered Feb 24 '15 at 12:13 AM

avatar image

twiddle
1.5k 55 36 73

avatar image GBicer Feb 24 '15 at 03:17 AM

I decided to use the Sphere Trace method, and while I got the trace to work, the editor keeps crashing when I add an OnHIt node to the actors I want to affect and then try to play in the editor. I guess this is something I'll have to wait on...

(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