Yeah that exactly how i use it. Only that i don’t use Events for that. Just getting the HUD from the Player Controller and set variables what to draw in my HUD.
You can still use Events to set those variables. Only that those Events are outside the HUD.
As i said before, With UMG you will be able to do such things in a more intuitive and streamlined way.
Why exactly do you think is complicated?
You could set a bool variable called “isGameOver” when the gameover event fires, and then when you are drawing the hud, use a Branch to check if the variable value is true, if it is, then run your end of game hud details, if it’s false, just use the normal hud.
The Hud draw is called many times per second (I think it is called on tick) so this should get the correct timing.
OK kids, I am learning - so @ajvnd - the whole idea of an Enum in general is question! But I am here to learn. And UMG is…(about to google it)
I think I did a little of both what you and @DotCam said - I had my custom events first set a boolean variable. When that variable is set to true a branch opens, and then flows through a gate that is opened by setting that variable.
It all ends up running through a sequence that linearly tests each branch to see what goes true when:
I know there are a lot of ways to solve problems, but is anything that I am doing TERRIBLY wrong in this solution? A concern I have is the constant testing of branches to see if the values are true. As @DotCam said, this is the tick of the HUD (right?) - will getting a number of these stacked in a row start causing noticeable lag?
In your BP, instead of using two branch statements, replace your “sequence” node with the branch and use the True output to go to the top part, and the false to the bottom, other than that is looks just fine.
A boolean operation is actually very cheap performance wise, you could have hundreds of them before you would notice any performance issues, Because it is only running one of the 2 operations (either true or false), and not having to run both true and false statements, it can actually save performance for you.
I would not worry about branches affecting performance, it is more the operations that occur after the branch you should be more worried about.
Just in case what I wrote was not entirely clear, I threw together a quick example of what I mean. I used a Timer and DrawText nodes only as an example, you could modify this and run your own functions in place of these:
@DotCam - I initially tried using the branch instead of sequence but I ran into trouble when both were true. If the condition was true, the second branch that would have triggered if false (if I stacked them) wouldn’t get a chance to be evaluated. I figured using a sequence I would step through and evaluate each situation as it does the work linearly. As I can add pins to the sequence, I can manage all my HUD calls this way.
Yes of course, I also use the sequence in mine as it makes things easier to compartmentalize, I just meant that if you have are using two separate HUD setups (one for normal in game, and a separate one for end of game) instead of using a sequence there, it would be simpler to just replace it with a branch, so that it would run the end of game hud if the value is true, and the normal hud on false. It just saves a step. But if using a sequence, you would then want only one branch afterwards (as in my image above) to run one or the other, as you don’t want to run both hud’s onscreen at the same time (or do you? let me know if I am not understanding correctly).
I just noticed in your last BP screenshot, you have both of them evaluating as true. You would want to instead have one using the false pin, otherwise both of them will run every time the hud is drawn, it would be better performance wise if it did not have to do this.
Let me know if this is the way you were intending it to work, I can expand on the example if it would help!
Ok - followup question. One of my messages says “One more to go” when they have all but 1 jewel they are collecting. If I put a delay, and then destroy actor on that specific draw text like this:
…I am not able to access the HUD again? It is almost like I destroy the HUD altogether with destroy actor, not leaving it to be used again. The message I do want to disappear DOES go away…but my “Level complete” message no longer functions when final jewel is collected.
I CAN get the level complete message to show up if I collect last jewel before the 3 second delay destroys the actor - so I know from that standpoint I have functionality.
How can I setup different drawtexts to be cleared after a specific time, or key press? Specifically I want the “One more go” message to disappear after x seconds - without affecting the rest of my HUD calls.
But as I using a boolean value to prevent the true side of the branch from running, I am not having each one run every time the hud is drawn, only when that boolean variable is set to true, right? I am not for example even hitting the gates for the each condition unless that specific boolean value is set to true. It IS continually testing on if they are true - is that a problem?
If I do it your way, won’t I only get a choice of only true / false, so 2 potential messages to the HUD?
Without using Ue4 speak, I want to be able to put up messages on the screen driven by events. Specifically:
“Welcome message” and instructions.
“1 more ring to collect” - when all but 1 ring is … collected.
instructions toggable bound to key.
a level over message with time it took to complete the level (I can do the timer later)
So I want to be able to draw and hide these at will, driven by events in the game, user input, or based on score for example.
For me the confusing issue is the single “Event Receive Draw HUD”. If I could have more than one of these (really, how can that be so hard? I don’t get it.) I would be able to separate these different messages.
Ok, so I cobbled together this to handle the message lasting for only x seconds before leaving. In essence I start with a boolean as false. The message is only sent to the draw text when made true (from event in scorekeeping blueprint). Then after a 2 second delay I set the boolean back to false. It doesn’t destroy the HUD / Draw Text, it simply stops sending data to it.
It functions…and it makes sense to my brain…please tell me if I going to break the matrix doing it this way.
Sorry I had to run out for a minute, but your setup in the screenshot should work, I don’t think you will break the matrix.
And what erWilly posted is definitely the way to go, pictures make things so much easier to explain, thanks for that erWilly. Things get complicated when using delay timers as every time the Draw Hud event fires, it would re-evaluate the same data without a gate (meaning it would create a new timer each time without a gate), so using gates will definitely be necessary to get the functionality you are looking for. Performance wise as well, the gate will make sure the different messages in your tree aren’t running unnecessarily.
For getting more than just one true/false, have a look into using a Switch statement, it is basically multiple Branch statements in one node that the blueprint would go through and test each case, and run only the ones that evaluate as true, that could be another way to go, but it can also be complicated to wrap your head around. Just keep it in mind if later you notice that you are using a lot of branch statements, as it could make it more readable.
Sorry I got a bit confused as to what you were wanting to achieve, but it looks you are on the right track now!