I recently created/used a time and date system (thank you Nebula Games). This was done C++ ActorComponent (I think this was a mistake). I have it loading and producing properly within my GameState (aka it displays a timestamp properly). Here is a snippet from my GameStateBP
I didn’t receive any compiling errors. Once I added the print string to let me know the cast was failing, I say it reported the cast was failing and of course due to the cast failing it was not putting the information into the HUD.
My problem: I do not understand why this is failing to cast. The C++ is working because it displays as expected when I play the level:
Any help would be appreciated. I feel like I should just do it as a different C++ file and not a component because its only in the GameState so that all players have access to it (so it replicates to all users).
Thank you all in advance o/
Quick Edit: I did make sure the gamestate is the same one set on the World Settings.
I chose the World_Date and “Current_Year” for the text. I verified the information was producing as a string. However when I run it now (the casting error is gone because there is no casting or any function at all since I found the properties as shown), but now that area is blank.
NOTE: For cause, I added the component to the scene’s sun
The data is available and showing in the scene debugger: (we will cover the This is not valid in a moment)
This returns us to the “This is not valid” As can be seen from my previous images, this is me checking the reference I created.
Here is my problem (updated problem as I try to resolve):
When I attempt to grabe the direct ActorComponent for reference (for the object section) I can “set it” or “get it” as expect. when I use a get, it still wants a target
on hover it wants CG Game State BP Object Reference. In my game state bp (as reference and as captured in the first image of my original post) is where my function is to start the game calendar/time. No matter what option I choose, I am unable to get it to resolve as it just wants another target.
I am compoletely unsure what I need to reference. If I promote the target to a local variable, it still shows blank and fails the is valid. UGH Please someone help me fix my brain on this
I don’t entirely understand why the actor component is necessary. Why not just move all of your time logic to a C++ GameState class and cast to it via the “GetGameState” blueprint node?
Thank you for responding, that is exactly what I did. I was going off an idea of creating actor components for an actor I was going to call time. Was a flawed concept. Going to mark yours as the answer, because that is again, what I ended up doing.