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"

Effecting post processing settings through player input with C++

I'll preface this by saying that I am very new to C++ and fairly new to coding in general so I apologize if my code or terminology isn't up to par.

I've got a game at the moment that picks up audio input from a microphone and plays it back through the speakers with a 0.4 second buffer. My question is how can I use C++ to increase a post processing effect (bloom intensity for example) while the player is making noise and then decrease the effect while they aren't?

The function in the .cpp file that actually plays the audio back is as follows:

 void AFH04Character::PlayVoiceCapture()
 {
     if (!PlayVoiceCaptureFlag)
     {
         VoiceCaptureAudioComponent->FadeOut(0.3f, 0.f);
         UCameraComponent* FirstPersonCameraComponent(float BloomIntensity = 1000.f);
         return;
     }
     if (VoiceCaptureAudioComponent->IsPlaying())
         return;
     UCameraComponent* FirstPersonCameraComponent(float BloomIntensity = 1.f);
     VoiceCaptureAudioComponent->Play();
 }

This all compiles fine and the audio plays back fine, but the post process effects don't actually happen in the game itself.

Product Version: UE 4.18
Tags:
more ▼

asked Nov 28 '17 at 06:41 AM in C++ Programming

avatar image

MagicDime
21 1 2 2

avatar image MagicDime Dec 03 '17 at 05:55 PM

I may have found the answer for what was wrong with my syntax here

I'll be trying it out as soon as I get home tonight, will keep you all updated!

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

1 answer: sort voted first

Alright I finally figured it out, you need to set a variable to carry the post processing data through a struct FPostProcessSettings myVar and then also set it to be able to override. Here's basically what's needed:

  //.h
 //Create your camera component
         UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
         class UCameraComponent* CameraComponentName;
 
 //create your variable that will carry the post processing data that you want affected
         UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
             struct FPostProcessSettings VariableName;
     
     
     //.cpp
 //Initiate your variable
         FPostProcessSettings VariableName;
 
 //Allow your variable to override the setting that you want to affect
         VariableName.bOverride_BloomIntensity = true;
 
 //Set the variable to the value you want for your setting
         VariableName.BloomIntensity = 50.f;
 
 //Get the post process settings of your camera and set them to your variable
         CameraComponentName->PostProcessSettings = VariableName;

You might need to #include "SceneManagement.h" and/or "SceneInterface.h"

With this, you can have a function that sets your variable- in my case, bloom intensity- to one value on an if statement and to another value on your else or another if like so:

 void AMyCharacter::DynamicPostProcessing()
 {
 
 if (itsDarkOut)
 {
 FPostProcessSettings VariableName;
 VariableName.bOverride_BloomIntensity = true;
 VariableName.BloomIntensity = 0.f;
 CameraComponentName->PostProcessSettings = VariableName;
 return;
 }
 
 if(itsBrightOut)
 {
 FPostProcessSettings VariableName;
 VariableName.bOverride_BloomIntensity = true;
 VariableName.BloomIntensity = 10.f;
 CameraComponentName->PostProcessSettings = VariableName;
 return;
 }
 
 }


Feel free to check the API here for a list of the different values you could control this way!

more ▼

answered Dec 04 '17 at 12:45 AM

avatar image

MagicDime
21 1 2 2

(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