Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Camera Shake C++ not working


I've tried to move my code from blueprint into C++ for camera shake, but apparently it's not working

Here's the code

 UCameraShake* CameraShake = ConstructObject<UCameraShake>(UCameraShake::StaticClass());
 CameraShake->OscillationDuration = -1.0f; //negative value will run forever
 CameraShake->RotOscillation.Pitch.Amplitude = 1.0f;
 CameraShake->RotOscillation.Pitch.Frequency = 0.5f;
 CameraShake->RotOscillation.Pitch.InitialOffset = EInitialOscillatorOffset::EOO_OffsetRandom;
 CameraShake->RotOscillation.Yaw.Amplitude = 1.0f;
 CameraShake->RotOscillation.Yaw.Frequency = 0.5f;
 CameraShake->RotOscillation.Yaw.InitialOffset = EInitialOscillatorOffset::EOO_OffsetRandom;
 Controller = GetWorld()->GetFirstLocalPlayerFromController()->PlayerController;
 Controller->ClientPlayCameraShake(CameraShake->GetClass(), 1.0f);

Here's the blueprint call and the testCameraShake class that is used on blueprint alt text

alt text

I've seen answers on https://answers.unrealengine.com/questions/2754/camera-bobshake.html but the solution don't reflect to my issues, checked on the values with debugger and see it populated correctly (I think)

Anything I missed? Thanks!

Product Version: Not Selected
blueprintcall.png (81.8 kB)
camerashake.png (47.8 kB)
more ▼

asked Nov 10 '14 at 08:47 AM in C++ Programming

avatar image

48 10 13 14

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Turns out to make it work I only need to make changes on the CameraShake initialization it into this

 CameraShake = UCameraShake::StaticClass()->GetDefaultObject<UCameraShake>();

I realize it from checking inside UCameraModifier_CameraShake::InitializeShake and seeing the value of SourceShake is not using the value I set up with

more ▼

answered Nov 11 '14 at 02:57 AM

avatar image

48 10 13 14

avatar image KillerPenguin Jul 10 '15 at 03:27 AM

Just a notice. This code in broken in 4.8 and still need to be fixed...


avatar image soulsource_ag Jan 31 '17 at 10:54 AM

Maybe I'm getting this wrong, but what you get with UCameraShake::StaticClass()->GetDefaultObject() is the class default object (CDO) from which all instances of UCameraShake are copied. Are you sure this is the way to go?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question