This question was created in reference to: [Gameplay Camera How to UBlueprintCameraVariableTableFunctionLibrary::SetFloatCameraVariable in [Content removed]
Further down this discussion, I try to call UBlueprintCameraVariableTableFunctionLibrary::SetFloatCameraVariable after UBlueprintCameraDirectorEvaluator::ActivateCameraDirector is already called, I can confirm my variable in set correctly (see my “MyAperture” variables below). I deliberately set it to a large value 22222222222222.
[Image Removed]
[Image Removed]
Hoever, with variable being set, the actual camera rig’s variable binding is not working correctly.
[Image Removed]
MyAperture variable won’t show up in debugger.
[Image Removed]
Debugger view matches with C++ Debugger. I guess it must be issues with FCameraEvaluationContext.
[Image Removed]
[Image Removed]
There is API with UBlueprintCameraDirectorEvaluator::GetConditionalContextResult and UBlueprintCameraDirectorEvaluator::GetInitialContextResult, none of this works correctly.
Any suggestions are appreciated. Thanks!
[Attachment Removed]
Hello! Thanks for trying out GameplayCameras.
First, about the related question: one reason I didn’t export those Blueprint functions to external C++ modules is that I figured that if anybody wanted to do this in C++, they could hit the lower-level APIs that the Blueprint functions already use. If you want to set the value of a variable, and assuming you have an evaluation context, you would do something like:
EvaluationContext->GetInitialResult().VariableTable.SetValue(MyVariable, TheNewValue, true);
We are running into compiler limits for the number of exported symbols, so we try to not export more classes and functions than we absolutely need.
Now, back to this question… I assume you ended up calling SetFloatVariable in Blueprint instead of C++? If so, maybe there’s a problem with what evaluation context you’re passing? Can you post a screenshot of your Blueprint Director?
According to your screenshots, the SetFloatVariable function correctly adds the new MyAperture variable to the variable table, but the following screenshots don’t have it anymore. The Lens Parameters node has a variable table that doesn’t have it, which is actually strange because since its Aperture property is bound to that MyAperture variable, it should have allocated that variable in the table from the beginning…
Do you have some repro steps for this problem? Or maybe a sample project you can share?
[Attachment Removed]
Ah I see, thanks. Indeed, now that you point it out, some of these functions don’t work outside of the evaluation loop, yes. Although I’m spitting out warnings in the log when that happens. Did you get these warnings?
Also, how do you get to the camera director object anyway? Since it’s created deep inside the camera system code, I figured it would be tricky to get to it and call things outside of the loop… did you add some custom accessors?
[Attachment Removed]
Hey there, development on Gameplay Cameras has been halted. There are currently no plans for further development. If development gets picked up later, we’ll go through reports like yours to inventorize what bugs and feature requests exist for the plugin. Unfortunately, for the time being that’s all we have to share.
[Attachment Removed]
Hi, [Content removed]
Later, I actually figured out how to make it work … I have to call SetFloatCameraVariable inside UBlueprintCameraDirectorEvaluator::RunCameraDirector. Any UBlueprintCameraVariableTableFunctionLibrary::SetFloatCameraVariable or UBlueprintCameraDirectorEvaluator::GetInitialContextResult call outside UBlueprintCameraDirectorEvaluator::RunCameraDirector and use FBlueprintCameraEvaluationDataRef outside UBlueprintCameraDirectorEvaluator::RunCameraDirector (call early or call later) will not properly register value for evaluation context.
Since I use Hazelight Studio’s modded angelscript engine, I can’t extract a sample. Hope this clear things a bit. Working angelscript code, where UMyCameraDirectorEvaluator is a wrapper around UBlueprintCameraDirectorEvaluator to provide some utility function:
class UMyScriptCameraDirectorEvaluator : UMyCameraDirectorEvaluator
{
UPROPERTY()
UCharacterCameraSettings CameraSettings;
UPROPERTY()
UFloatCameraVariable FocusDistanceVariable;
UPROPERTY()
UFloatCameraVariable FocusLengthVariable;
UFUNCTION(BlueprintOverride)
void ActivateCameraDirector(UObject EvaluationContextOwner,
FBlueprintCameraDirectorActivateParams Params)
{
FocusDistanceVariable = Cast<UFloatCameraVariable>(FindCameraVariable("FocusDistance"));
FocusLengthVariable = Cast<UFloatCameraVariable>(FindCameraVariable("FocusLength"));
}
UFUNCTION(BlueprintOverride)
void RunCameraDirector(float DeltaTime, UObject EvaluationContextOwner,
FBlueprintCameraDirectorEvaluationParams Params)
{
ActivateCameraRig(CameraRig, false);
FBlueprintCameraEvaluationDataRef CameraData = GetInitialContextResult();
if (CameraSettings != nullptr)
{
if (FocusDistanceVariable != nullptr)
{
CameraVariableTable::SetFloatCameraVariable(CameraData, FocusDistanceVariable, CameraSettings.FocusDistance);
}
if (FocusLengthVariable != nullptr)
{
CameraVariableTable::SetFloatCameraVariable(CameraData, FocusLengthVariable, CameraSettings.FocusLength);
}
}
}
}
Thanks,
Wuxiang
[Attachment Removed]
Hi. Unfortunately I don’t recall seeing any warnings … I managed to expose UBlueprintCameraDirectorEvaluator in this way (before I found out it is not necessary and harmful):
class FBlueprintCameraDirectorEvaluator : public FCameraDirectorEvaluator
{
// Wuxiang >> Expose evaluator blueprint
virtual const class UBlueprintCameraDirectorEvaluator* GetEvaluatorBlueprint() const override { return EvaluatorBlueprint ? EvaluatorBlueprint.Get() : nullptr; }
virtual class UBlueprintCameraDirectorEvaluator* GetEvaluatorBlueprint() override { return EvaluatorBlueprint ? EvaluatorBlueprint.Get() : nullptr; }
// Wuxiang <<
private:
TObjectPtr<UBlueprintCameraDirectorEvaluator> EvaluatorBlueprint;
};
Wuxiang
[Attachment Removed]