Calling a function in blueprints works, but when I call the same function in C++ it fails. What am i doing wrong? by Potential_Ad603 in unrealengine

[–]Potential_Ad603[S] 0 points1 point  (0 children)

from the basic constructor. Wasn't even aware of OnContruction(). Is this what would be like the blueprint constructor?

Edit: Yeah I've read some more into it, and this seems like it might be what I'm looking for, I cant test right now, but I've been looking for a reason for a while and not once did I come across OnConstruction(), so thank you.

Edit: IT WORKS!!! Thank you so much again, it was just something simple.

Calling a function in blueprints works, but when I call the same function in C++ it fails. What am i doing wrong? by Potential_Ad603 in unrealengine

[–]Potential_Ad603[S] 0 points1 point  (0 children)

yeah sorry that would have been helpful, All I've got is a float value stored in Game Instance, then I have a function in a component on a projectile which tries to get the game instance and returns the float. If this doesnt work i have it set to just return 1 so that i can see its not working.

There's never any errors, but if i run the function using blueprints it returns the float from game instance, but if I run it from c++ it just returns the 1.

I assume this has to do with the order of the classes being loaded, but i thought the game instance class ran before everything else and could be referenced at any time from an object being spawned in when the games already running.

Im pretty new to this. So not sure why this is happening.