top of page

UE4 Blueprint Interfaces : GameTime

This is just an easy thing I did to show what a blueprint interface can do in UE4. You can simply find GetRealTimeSeconds from within HUD, but the example is just about making an interface work so instead we get in GameState ... (who knows, maybe it's obtained there and some processing is done to it you don't want to have to do again in the HUD).

An interface asset contains a function, say SendTime, and it contains a string variable called SentTime.

GameState populates it with the string result of GetRealTimeSeconds (clamped from a float to an integer first using Floor). Then a Messenger call to the interface sends the info off to the HUD blueprint (via casting done on BeginPlay). The GiveTimeToHUD function is actually called in the HUD each EventRecieveDrawHUD.

Then the HUD draws the result if a bool is true. I controlled the ShowTime bool in PlayerController using Spacebar. There's a bit of back and forth handshaking in this example, but what you end up with is a cozy way of toggling the duration of gameplay on screen.

WEB_INTERFACE.png

Featured Posts
Recent Posts
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page