I finally got around to buying UE4 about a week ago and have been attempting to learn how to program through blueprint (I have no experience with code and would be hopeless with C++). I’ve been fiddling on and off with figuring out how to open and close a door (seemed like a good place to start). I’ve nearly completed most of the functionality I want (well, for now at least. I’ll explain further down) but I’ve ran into an interesting problem.
The method for opening the door I chose to go with is a line trace that allows the player to open the door upon pressing F so long as they are in range and looking at the door. The code I had worked just fine, however, I wanted to cleanup the graph and so I consolidated things within functions to save space. Everything worked fine except for the Check Usable Object function (the line trace). As far as I can tell there is no reason for the error I am getting, but I’m sure there is something I don’t know about that is going on. Anyway, to make things easier than my—usually incoherent—ramblings, I’ve screencapped the script (is it script or code or graph or something else?) in question.
Everything looks fine and dandy, but, as I said above, the Check Usable Object function is giving me problems. Here is a picture of the function.
(Note: I had actually added a Switch Has Authority node before the line trace, I just took the screencap before then)
The problem I am having is: once the line trace hits the door, no matter where I go, the door can be triggered to open and close despite the line trace no longer hitting the door. To make sure I didn’t just somehow script things wrong (even though I copied the original script directly into the function when I was consolidating things) I tried the same script but exposed in the event graph rather than in custom function.
This fixed the problem and I have no idea why. By chance do any of you guys know what amateur error I made?
Also, I had a couple questions beyond that I would like to ask. First, I would appreciate if you guys could give a look over of the rest of my script and tell me if I have any redundancies I could get rid of or if I’ve made anything that won’t function the way I’m expecting (with both the Use script above and the door script below).
Beyond that I was wondering how I would go about adding an icon to the HUD to show the door can be opened/closed similar to that of ArmA 3. By that I mean an actual HUD element rather than a widget that pops on in in front of the door. I have no HUD script set up at the moment, though (probably worth mentioning as I figured it may affect possible answers to my question).
Eventually I will have other questions as well (as the door model I was testing this on will one day be part of a player created wall in part of a player built base), but I think I’ve asked enough for now. Any and all help is appreciated.