Download

UCameraShake not working?

Been trying everything I can but nothing seems to work.

This is in my pawn class:


CameraShaker = UCameraShake::StaticClass()->GetDefaultObject<UCameraShake>();
CameraShaker->OscillationDuration = -1.0f;
CameraShaker->RotOscillation.Pitch.Amplitude = 1.0f;
CameraShaker->RotOscillation.Pitch.Frequency = 0.5f;
CameraShaker->RotOscillation.Pitch.InitialOffset = EInitialOscillatorOffset::EOO_OffsetRandom;

CameraShaker->RotOscillation.Yaw.Amplitude = 1.0f;
CameraShaker->RotOscillation.Yaw.Frequency = 0.5f;
CameraShaker->RotOscillation.Yaw.InitialOffset = EInitialOscillatorOffset::EOO_OffsetRandom;

And then I call this:


Cast<ASwatterPlayerController>(Controller)->ClientPlayCameraShake(CameraShaker->GetClass(), 1.0f);

From what I can tell, my set variables for the UCameraShake are getting squashed because of this call in CameraModifier_CameraShake.cpp:


UCameraShake* const NewInst = NewObject<UCameraShake>(this, ShakeClass);

Which just creates a default object that has OscillationDuration set to 0.

Am I doing something wrong here?

https://forums.unrealengine.com/showthread.php?17004-Camera-Shake-and-Camera-Animation works fine for me in 4.10

How would I be able to link the blueprint to the TSubclassOf though if my pawn is instantiated in C++?

Actually, I think I see what I need to do, subclass the CameraShake class and then supply my own default variables for that class type.

That worked, but there seems to be a bug where setting OscillationDuration to < 0 doesn’t make it run indefinitely, even though there’s code and comments in the class that seem to imply that it should work like that.