Download

C++ Dynamic Curves

Hi all

Extremely noob here in Unreal programming. Fairly good in C++.

I have some code and a some blueprint assets. Specifically, there’s a curve (RotationAngles_Curve):
Capture.PNG

and a BP timeline that uses this curve:

I would like to refer to the Curve from C++ and change/add values to it. The end aim is that the timeline would be dynamically edited - the curve set in runtime.

How would I go doing that?

Thanks!

Thanks, mate.
What I don’t know is how to reference the specific curve I have in the engine…
@OptimisticMonkey, any leads?

This might help:
https://youtube.com/watch?v=KsvUYzrTwBw
Another reference point (this person just posted a question also but provides code:)

https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1746072-ucurvefloat-does-not-exist-in-binded-function

Thanks, but no dice. At least I didn’t get it.

Simply put: I have a VectorCurve Existing in the Content Manager. I’d like to add points (key, values) to it through code. For that, I first need a way of referencing it.

in the constructor:



/* This is the way using a Blueprint Curve */        
static ConstructorHelpers::FObjectFinder<UCurveFloat> PlayCurve(TEXT("/Game/Blueprints/Utils/Curve_PlayRotation_Float"));    
check(PlayCurve.Succeeded());
PlayRotation = PlayCurve.Object;


static ConstructorHelpers::FObjectFinder<UCurveFloat> DeathCurve(TEXT("/Game/Blueprints/Utils/Curve_DeathRotation_Float"));
check(DeathCurve.Succeeded());
DeathRotation = DeathCurve.Object;



and then in begin play:



PlayRotation = NewObject<UCurveFloat>();
PlayRotation->FloatCurve.AddKey(0.0f, 0.0f);
PlayRotation->FloatCurve.AddKey(1.0f, -360.0f);

DeathRotation = NewObject<UCurveFloat>();
DeathRotation->FloatCurve.AddKey(0.f, 0.f);
DeathRotation->FloatCurve.AddKey(1.f, -512.f);