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"

how to enable/disable input using raycast

How can I enable input when a ray hits an object(in my case a lamp) so if I press "F" I can turn the light ON/OFF and disable the input when the ray is not hitting the object so if I'm away and I press "F" I cant turn the lights ON/OFF.

with a helpful message that says "press F" when the ray hits that certain object.

Product Version: UE 4.9
Tags:
more ▼

asked Oct 09 '15 at 01:51 AM in Using UE4

avatar image

divine123
13 6 12 14

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

3 answers: sort voted first

I think this is actually much simpler

What I did is I created a new interface for the toggling. so basically the interface to show the helpful message is another interface. alt text

less nodes but same function. well as of now I can work with this one. alt text

answer_001.jpg (66.7 kB)
answer_002.jpg (53.0 kB)
more ▼

answered May 18 '16 at 03:32 AM

avatar image

divine123
13 6 12 14

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

This is pretty simple...

  1. Get the camera position / actor position

  2. Get the camera orientation, then convert that into a look vector.

  3. Place the look vector at the camera eye position

  4. Scale the look vector by the distance you want to search for objects

  5. Apply a "Line Trace by Channel" node, with the eye position and look vector as end points

  6. Grab the "Hit Actor" from the hit result

  7. Cast the hit actor to the light switch blueprint. If the hit actor is a light switch, the cast will succeed. Then, you can activate a bool flag within the player character which enables the "F" input button.

  8. When the player activates their input button, you should send a message to the 'looked at' actor and tell it to toggle itself. I recommend blueprint interface messages so that you can have multiple switch types. See the content examples for an example of this.

more ▼

answered Oct 09 '15 at 02:04 AM

avatar image

Slayemin
824 50 29 73

avatar image divine123 Oct 09 '15 at 03:02 AM

thanks for the response, thats actually where I am right now. I'm goin put my graph so you can see :)

avatar image divine123 Oct 09 '15 at 03:43 AM

ok so heres my graphs. INTERFACE alt text FIRSTPERSON LINE TRACE alt text and heres where I'm having some problem,. so I can enable input but I dont know how to disable it when the ray is not hitting the object. So once the ray hits the object, it stays enable all the time and I can toggle the light even if I'm away. alt text if I can just disable it when the ray is not hitting the object. alt text

interface.jpg (112.8 kB)
fps.jpg (125.6 kB)
mylamp.jpg (131.5 kB)
ingame.png (368.1 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You should create a variable for the currently selected object. If your line trace succeeds and hits a valid object type, then you set the currently selected object to that object. If the line trace hits a non-usable object, then you set your currently selected object to "null". When you go to interact with the currently selected object, put a "IsValid" macro node before trying to use it.

more ▼

answered Oct 09 '15 at 03:54 AM

avatar image

Slayemin
824 50 29 73

avatar image divine123 Oct 09 '15 at 07:04 AM

wow you really are knowledgeable about blueprints and I'm not. I'm really sorry I'm a newbie. you lost me with that, I think I need to learn a lot first before to get that working huh? :(

but thanks for the reply ;)

avatar image divine123 Oct 09 '15 at 08:15 AM

Ive been tweaking with the graphs still cant make it work. can you give me an example graph.

avatar image Slayemin Oct 09 '15 at 10:27 PM

Yeah, here is a series of screen shots from my 'target locking' system which uses the line traces and target selection, similar to what you're trying to do. This should help you get on the right track!

Part 1 Part 2 Part 3 Part 4

If you want to see the complete blueprint, you can stitch these images together in your favorite image editor. I took screenshots from left to right.

1.jpg (221.0 kB)
2.jpg (227.4 kB)
3.jpg (195.5 kB)
4.jpg (208.9 kB)
(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