x

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"

4.8 CameraShake broken (c++)

Since unreal upgrade to 4.8,of c++ camera shake seems to be broken.

Hope someone can fix this. Thx.

Product Version: UE 4.8
Tags:
more ▼

asked Jul 07 '15 at 12:05 AM in C++ Programming

avatar image

KillerPenguin
186 12 17 38

avatar image Doug E ♦♦ STAFF Jul 07 '15 at 06:11 PM

Hey KillerPenguin-

Do you have additional information on how it's broken? Can you post the code where you're using camera shake? Additionally, a short video of what you're experiencing will help us understand exactly what's happening.

Cheers

Doug Wilson

avatar image KillerPenguin Jul 08 '15 at 01:26 AM

Well, you can grant at code from another's post here ->

https://answers.unrealengine.com/questions/246179/camera-shake-not-work-after-upgrading-to-48.html

However, the only solution provided was 'using BP instead of c++'. Something we couldn't do. Hope you fix this soon.

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

1 answer: sort voted first

Hey KillerPenguin-

I was able to solve the issue with the code setup in the post you linked to. You can check the solution there to see if that helps you with your project.

Cheers

Doug Wilson

more ▼

answered Jul 09 '15 at 04:06 PM

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

Sigh... so you would force us to make a UPROPERTY out of UCameraShake? What happen if my UCameraShake is code generated? And there could so many of them playing at the same time? As I said beforemI don't want a BP solution. Right now C++ side seems to be broken

:/

This is my code which used to work in 4.7:

UCameraShake* nCameraShake = UCameraShake::StaticClass()->GetDefaultObject();

/ do stuff like editing its new propoerty/

nPlayerControl->ClientPlayCameraShake(nCameraShake->GetClass(), 1.f);

avatar image Doug E ♦♦ STAFF Jul 10 '15 at 01:29 PM

The fact that that method worked in 4.7 may have actually been a bug. As I mentioned in the answer on the other post, in this case you are calling ClientPlayCameraShake and passing in the base CameraShake class rather than the nCameraShake object that you've made changes to. Since it is using the base class it will use the base class defaults instead of your changes. Using the blueprint was simply the easiest solution, something else you can try would be to create your own class (MyCameraShakeClass) based on UCameraShake and then make your nCameraShake a subclass of that and change the defaults in your MyCameraShakeClass. I have not tested this method however it should work as the code equivalent of using the blueprint.

avatar image KillerPenguin Jul 14 '15 at 01:05 AM

Ok, so if I don't want any to change any defaults but create each one with unique properties, how do I do that?. I'm asking you this since most of the time my CameraShake is code generated in real time, and I can't have one Shake change the defaults properties of the others.

avatar image Doug E ♦♦ STAFF Jul 14 '15 at 02:12 PM

Hey KillerPenguin-

Without looking at the code directly the best suggestion I can give would be to make a function that you can pass the default values to when you want to do a camera shake. If the defaults are passed into the same function then you can define the parameters of each camera shake by which values get passed to the function. The function then sets defaults and calls camera shake as explained in the other post. Again without seeing how your code is being implemented I can't say how effective this would be in your case.

Cheers

Doug Wilson

avatar image KillerPenguin Sep 11 '15 at 01:36 AM

The way I look at it, changing defaults of a base object and pass the same thing over and over to a function is hardly ideal. Can't you make the

ClientPlayCameraShake( TSubclassOf< class UCameraShake > Shake)

into this? (Or at least a new function)

ClientPlayCameraShake( UCameraShake Shake)

That way we can just create a new object and pass it in.

ps. here's the code:

 UCameraShake* nCameraShake = NewObject<UCameraShake>();
 nCameraShake->LocOscillation.X.Amplitude= x;
 nCameraShake-LocOscillation.X.Frequency = y;
 nPlayerControl-ClientPlayCameraShake(nCameraShake->GetClass(), 1.f);


It's the "GetClass()" that prevents us from doing wonderful thing here.

Right now, we just have to go to BP and create new default shake every single time. Not very c++ supportive here...

avatar image KillerPenguin Sep 11 '15 at 03:01 AM

In fact, speaking from c++ view, CameraShake shouldn't even be an UObject in the first place..

avatar image Doug E ♦♦ STAFF Sep 11 '15 at 04:07 PM

Hey KillerPenguin-

If you create a class based on CameraShake (CustomShake) and make nCameraShake a child class/subclass of CustomShake then you can write a function in CustomShake that takes in the values you want to use when ClientPlayCameraShake() is called. So prior to calling nPlayerControl-ClientPlayCameraShake(nCameraShake->GetClass(), 1.f); you can call this SetDefaults() function. You would still have to pass in the default values to be set but unless you have more than one camera shake playing at a time, this would offer better performance than having to create a new object and set its defaults every time you wanted the camera shake to play.

avatar image KillerPenguin Sep 23 '15 at 09:13 AM

There is SetDefaults() function? I failed to find it anywhere in the UE document.

How do I implement it?

avatar image Doug E ♦♦ STAFF Sep 23 '15 at 01:52 PM

Sorry for not being clearer. I was referring to "SetDefaults" as a custom function that you can create/call to set defaults based on how you want the camera shake to react. Since you mentioned having different situations where the camera shake is different, it would be easiest to create a function that sets the necessary values based on what is passed into the function when it is called.

avatar image KillerPenguin Sep 24 '15 at 12:46 AM

Err.. I've tried that.

However, whenever I tried to set new values before passing in my new cameraShake class, nCameraShake->GetClass() always revert back to the initial value declared in construction script.

Thus, there's really no way to dynamically set defaults with c++. That's why I'm complaining about this GetClass() stuff in the first place.

So anyway to solve this?

avatar image Doug E ♦♦ STAFF Sep 25 '15 at 04:10 PM

Hey KillerPenguin-

nCameraShake->GetClass() returns the initial values because the ClientPlayCameraShake() function takes in a TSubclassOf which will always return the default of the specified class. You can check the answer in the following link for more information on this:

https://answers.unrealengine.com/questions/63601/tsubclassof-get-pointer-to-object-of-type-class.html

If you have multiple camera shake effects with different settings, the only answer I've found would be to have different UCameraShake blueprints (each with their own defaults set) along with different TSubclassOf. Inside your player blueprint you can assign each of the TSubclassOf variables to a different blueprint default and then in the code when you call ClientPlayCameraShake you pass in the appropriate TSubClassOf variable.

Cheers

Doug Wilson

avatar image KillerPenguin Sep 28 '15 at 06:33 AM

Yeah, so back to my point that since 4.8 we can't dynamically create any useful shake from c++.

avatar image Doug E ♦♦ STAFF Sep 28 '15 at 02:03 PM

As mentioned previously, the implementation that worked previously may have been incorrect functionality. Since ClientPlayCameraShake() takes a TSubclassOf, I iwill put in a request to be able to edit the class defaults through code or allow the function call to accept an object pointer.

(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