Error/Bug when creating a haptic curve in runtime

I have this odd issue when trying to control the haptics from code, it will play the haptics for about 100-150 collisions and then will just get inside an error. This is what I am doing:

Instantiating the curve

hCurve = NewObject<UHapticFeedbackEffect_Curve>();
aExternalCurve = NewObject<UCurveFloat>();
fExternalCurve = NewObject<UCurveFloat>();

Adding the curve keys based on the hit

aExternalCurve->FloatCurve.AddKey(0, 1.0f);
fExternalCurve->FloatCurve.AddKey(0, 100.0f);

aExternalCurve->FloatCurve.AddKey(0.3f, 1.0f);
fExternalCurve->FloatCurve.AddKey(0.3f, 100.0f);

Playing the curve

myPlayerController->PlayHapticEffect(hCurve, EControllerHand::Right);

Resetting the keys when the next hit happpens

myPlayerController->StopHapticEffect(EControllerHand::Right);
aExternalCurve->ResetCurve();
fExternalCurve->ResetCurve();

CallStack

The error occurs in FActiveHapticFeedbackEffect’s update method, the happticEffect->GetDuration() gets access error although the HapticEffect is not null. Am I missing anything? or is it a bug in the engine?

Things I tried:
-Using EditorCurve (from the cpp, not the editor) instead of ExternalCurve
-Changing the strtuct of the curve directly
-Creating a new curve object every single time instead of creating it once as a variable and resetting it
-Stopping the previous haptic and clearing cooked data on hit

All of them led to working haptics for 100-150 hits, and that same crash. And yes, I do need to use the curve class because in the real code it creates a more complex curve.

1 Like

Still can’t find a way to solve it, I tried to create the haptic curve from the editor and just set it’s values from the cpp file but it still leads to that same issue.