I am not really coding a game but just getting a feel for the system to see if its realistic for me to even try, YouTube has been a great source of help but im stuck in something that must be really simple but i am at a lost. First things first these are my Current Blueprints:
This is what im using to detect the interactable actors.
So the test im doing is i have two doors, one of them is done with a simple collision so when the Player Character capsule collides with the collision box you press the interaction key and presto it opens. However i want it so that the player has to actually look at it in order to do that so i “created”* the Blueprints above and the second door manages to open once i look at it, the problem is that after that it keeps on opening and closing even if im not looking at it.
After banging my head to the keyboard a couple times i noticed that when i did the original door i actually had a reset of that collision, and im sure that my answer is as simple as do the same but doing it with the Sphere Trace… Problem is that im not sure what functions to invoke, this is the Blueprint i have for the collision door:
Also i realized that the reset i posted earlier is for the viewport which in essence just shows a “Press E to Interact” on the screen but i feel like it might be the clue to unbind (i think that is the term) the door from the control of the player after the player is no longer in range of the sphere trace, so i tried to this:
And that proved to be a failure, but i feel like the OnActor Hit event might be the right path, i just have to implement it correctly, because it does not even show me the press E to interact so im doing something wrong but not sure what right now.
For as along as the Hit Actor reference is valid, the IA Interact will be happy to send it interface messages. And this variable remains valid until we override it with another value. Which means it will be valid pretty much all the time.
Depending on how the game works, there’s more than one solution here. Let’s start with the most straightforward:
run the line trace script on IA Interactinstead. It does not do anything special when IA Move & Lookaround calls it. You would not even need a variable this way.
You may have other plans for the interaction later on (like having “Press E to Interact” pop up), or some other mechanics will kick in. But for now, see if you can make it behave correctly without the prompt.
Regarding the Reset, you can assign and un-assign values like so:
Leave the dropdown blank to make it null. You could nullify if when the player moves away and ends overlap, for example. This may not be necessary if you apply the solution mentioned in the bullet point.
Do tell how it goes.
If you prefer to take your time, consider exploring this:
It’s a similar setup where nearby objects pop up icons that highlight when looked at, and can then be interacted with. There is a project attached if you want to take it for a spin.