Hi everyone I am just getting into Unreal C++, and I was wondering if it is possible to call a blueprint function using c++.
I am writing a fairly advanced day/night cycle and it would be inefficient to do all the calculations in blueprints, so I’m writing the calculations in c++ and then want to rotate the light source and call the update skySphere function.
If your SkySphere and directional light (sun) are already created in the editor, you can search for them in your c++ code (in BeginPlay for example) and store the reference to it there.
for (TActorIterator ActorItr(world); ActorItr; ++ActorItr)
{
if ((*ActorItr)->GetName().Equals("SkySphere")) // Adapt to the name of your Sky Sphere
{
mSkySphere = *ActorItr;
// quits the loop if both actors are found
if (mSunLight != nullptr)
{
break;
}
}
if ((*ActorItr)->GetName().Equals("DirectionalLightSun")) // Adapt to the name of your directional light (your sun)
{
mSunLight = (ADirectionalLight*)(*ActorItr);
// quits the loop if both actors are found
if (mSkySphere != nullptr)
{
break;
}
}
}