How to make a simple interaction system?
How to make an interaction system were for example I click E to pick up or show an item while flouting to inspect it or E to activate an audio or E to move something or click a button to open doors you know what I mean now
asked Jan 15 '19 at 05:50 AM in Using UE4
ok so what we wanna do is make a blueprint inter face then go inside that rename the new function to interact then we wanna go inside the item we are interacting with and go to class setting and set the interface then in then event graph you wanna do event interact and then run your code then go to you project settings and set a new input action select the key you wanna use and then go to your character and get the input action interact and check if the item implements the interface which which class would be interact interface if it does then you wanna call its interact message see screen shots for full code hope it helps
answered Jan 15 '19 at 06:08 AM
What you are asking could have a lot of approaches and objectives but if you are doing a first person or third person game, what first comes to mind here is:
-On the event of pressing the E key:
-Line trace (channel):
-From: Center of the screen
-To: Forward vector of the rotation of the camera, times the reach in distance you want it to have, + camera location (someone correct this if it is wrong)
-Then check if the trace hit a grabbable object by:
-"Equal (object)" at the "hit actor" or "hit component" output of the trace as you wish (split the output struct of the trace to find this), and compare them to the actor or component you wanna know if was hit by the line. If it was a grabbable object, bingo.
-You might wanna chain some branches at the falses of other branches to check for different objects.
This is just a way to do this. Then you can do whatever and fire whatever action or event with that object found by the trace. Lemme know.
answered Jan 15 '19 at 06:12 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here