Download

Some parameters values hardcoded in c++ are not set , instead it works by setting in detail panel

Hi all, thanks to my english, maybe the title could be a bit bad…but the things is:
Some things that i set in code for a simple rolling ball pawn in c++, like:
-the ball static mesh component’s scale
-the set simulate physics boolean of the static mesh




if (SM_ball!=nullptr)
 {
  SM_ball->SetRelativeLocation(FVector(0.0f,0.0f,40.0f));
  SM_ball->SetWorldScale3D(FVector(5.0f));
 }

 // Setting up the Spring arm
 springArm->RelativeRotation = FRotator(-40.f, 0.f, 0.f);
 springArm->TargetArmLength = 400.0f;
 springArm->bEnableCameraLag = true;
 springArm->CameraLagSpeed = 3.0f;


 AutoPossessPlayer = EAutoReceiveInput::Player0;

 SM_ball->SetSimulatePhysics(true);



SM_ball->SetWorldScale3D(FVector(5.0f)); that before was set to 0.0f

SM_ball->SetSimulatePhysics(true);

these 2 instructions do nothing. Instead, placing this c++ pawn into the world and modifying the parameters in the detail panel, that works…i’m kinda confused

Thank you for your attention :3

I don’t follow you at all, I guess so.

If I have a API interface:

//h
UFUNCTION(BlueprintCallable)
static void test();

//cpp
void ???::test()
{
//…
GEngine->GetWorld()->GetGameState();//most of the time, GetWorld() is null
//…
}

If do this:

//h
UFUNCTION(BlueprintCallable)
static void test(UWorld* In);//!!!which do not need any given parameters in BP!!!

//cpp
void ???::test(UWorld* In)
{
//…
In->GetGameState();//is ok
//…
}

A handle will automate in BP.

Thanks for response but no, i try to explain it better:
Some values that i set via c++ code (for example this acually happened):

file.h
UPROPERTY(EditAnywhere)
float force;

file.cpp
???::constructor(){


force=5.0f;


}

The first time i compiled this code the variable force actually had a value of 5.0 but then when i modified its value to 10-> force=10.0f (i substitute that 5.0f with 10.0f) the variable kept stored 5.0f. However, when i set the force value to 10.0f in the detail panel of the ue editor, it worked. This things happened for the set simulate physics bool of a static mesh. I’m trying to figure out why this happened

Restarting the editor usually solves weird problems.

If you have already changed a value in the Editor details panel, as you mentioned, the editor will mark this variable as “dirty”, and it wont update the value from c++ anymore, no matter how much you change in the constructor. What will count is what you set in the Blueprint Class for now (I’m actually speculating it’s treated that way, but the results are that)

To solve this, if you see a little yellow arrow next to the variable and click it, it will set things back to normal for you. (what you are actually doing is reseting the value to default - c++ constructor)

Think of the Blueprint as the child class of the C++ class. The blueprint values are overriding the values in the parent C++ class.