Unreal DataStreams Guide
This guide was written as a quick reference step by step guide for setting up a simple Unreal datastream. For more in depth information on each step please check the documentation at https://www.genvidtech.com/for-developers/sdk-latest//
Download Clock Assets
Download the folder containing the assets for this guide
Import “clock_face” as a texture after creating your project (or you can drag and drop the clock folder into your content folder in explorer to get a pre-built clock)
Clock Setup
If you dragged and dropped the clock folder into your content folder skip this section
Create an object of type “Sprite” (Paper2d->Sprite)
Set the source texture as “clock_face”
Create a material and set it’s color to be black
Create a blueprint actor. Attach the following components:
A scene component attached to the default scene root named “Clock”
A scene component attached to “Clock” named “HourHand”
A cube component attached to “HourHand” named “HourHandCube”
Set the location to 75, 0, 0
Set the scale to 1.5, 1, .15
Set the material to the material created above
A scene component attached to “Clock” named “MinuteHand”
A cube component attached to “MinuteHand” named “MinuteHandCube”
Set the location to 0, 0, 100
Set the scale to .1, 1, 2
Set the material to the material created above
A scene component attached to “Clock” named “SecondHand”
Set the rotation to 0, 45, 0
A cube component attached to “SecondHand” named “SecondHandCube”
Set the location to 50, 0, 0
Set the scale to 1, 1, .075
Set the material to the material created above
A paper sprite component attached to “Clock” named “Face”
Set the Source Sprite property to the sprite created above
Finished component list for the clock
Create a function called “GetAngle”. This will be used to calculate an angle from a hour, minute, or second
It should have 3 float inputs: Min, Max, and Value
It should have 1 float output: Angle
Call “Normalize to range” passing in the value, min, and max inputs
Call “Lerp”. A is 360, B is 0, and Alpha is the value returned by “normalize to range”
Return the value returned by Lerp
GetAngle function
Create 3 variables of type float on the blueprint. Hour, Minute and Second.
On tick we want to set the hour value
The hour value should be in a 0 - 12 hour format allowing for decimals along the way. This value should then be passed into GetAngle. See the image below
Tick function for the clock
The Minute value should be between in a 0 - 60 format allowing for decimals along the way. This value should then be passed into Get Angle. See the image below
Tick function for the clock (Continuation from above)
The Second value should be between in a 0 - 60 format allowing for decimals along the way. This value should then be passed into Get Angle. See the image below
Tick function for the clock (Continuation from above)
Set the Pitch of the “HourHand”, “MinuteHand”, and “SecondHand” using “SetRelativeRotation” and the values calculated for each. See the below image
Note 60 will have to be added to the hour angle, and 90 will have to be added to the second hand
Add the Clock blueprint actor to the level in view of the camera. Confirm it is working correctly by hitting play

C++ Implementation
Open your C++ GenvidStreams class.
Create a function named “ClockTimeSteam” that returns FGenvidStream and takes no inputs. Add the following code:
FGenvidStream ClockStream; ClockStream.Name = "ClockTime"; ClockStream.OnGenvidStreamDelegate.BindUFunction(this, "OnSubmitClockTime"); ClockStream.Framerate = 30; return ClockStream;
This code declares a FGenvidStream, set’s its name, binds it to a function that doesn’t exist (yet), and sets its framerate to 30 before returning it.
Create a function called “OnSubmitClockTime”. Have it return void and take an input of type FString& named “Id”. Add the following code:
FClockTime ClockTime = GetClockTime(); FString ClockTimeString; FJsonObjectConverter::UStructToJsonObjectString(ClockTime, ClockTimeString); SubmitGameData(Id, ClockTimeString);
Make sure it has a UFUNCTION tag so it is bindable
You will need to add "JsonUtilities" to the “PublicDependencyModuleNames.AddRange” list in your .build.cs file
This function gets the clocks time using a function that doesn’t exist (yet) named GetClockTime.
Creates a JSON string that will have the final format of {“hour”:”<hour>”,”minute”:”<minute>”,”second”:”<second>”}
Calls an existing function on all GenvidStream classes called “SubmitGameData” that sends the stream
You may want to log the ClockTimeString and Id to make sure the values are correct
Id is the input parameter
Create a structure called FClockTime with an hour, minute, and second property:
USTRUCT(BlueprintType) struct FClockTime { GENERATED_BODY() public: UPROPERTY(BlueprintReadWrite, EditAnywhere) int32 Hour = 0; UPROPERTY(BlueprintReadWrite, EditAnywhere) int32 Minute = 0; UPROPERTY(BlueprintReadWrite, EditAnywhere) int32 Second = 0; };
Create a function called “GetClockTime” that returns a FClockTime with no inputs
Set the hour, minutes, and seconds in a new FClockTime instance
FClockTime ClockStream; ClockStream.Hour = FDateTime::Now().GetHour12(); ClockStream.Minute = FDateTime::Now().GetMinute(); ClockStream.Second = FDateTime::Now().GetSecond(); return ClockStream;
Override the BeginPlay function
Add the following code:
Streams.Add(ClockTimeStream()); Super::BeginPlay();
This adds the stream and binds the “OnSubmitClockTime” function using the function ClockTimeStream created above