Variable not taking effect

Just beginning with c++. I am trying to make MovementMagnitude to be editable in the UEditor but something is not right.

This is the header

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = MovementMagnitude)
		float MovementMagnitude;

float RunningTime;

This is the c++ file

// Called every frame
void AFloatingActor::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

	FVector NewLocation = GetActorLocation();
	float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
	NewLocation.Z += DeltaHeight * MovementMagnitude;
	RunningTime += DeltaTime;
	SetActorLocation(NewLocation);
}

MovementMagnitude is set to the value from the editor but NewLocation vector gets a strange value: X=0.000000000 Y=0.000000000 Z=-1.79213164e-014.

Are you initializing your MovementMagnitude to a value? Otherwise you’ll get some random junk value (which is probably what you are seeing).

In your constructor for AFloatingActor, you need to set it to 0.0f.

i.e.

AFloatingActor::AFloatingActor()
{
   MovementMagnitude = 0.0f;
}

or

AFloatingActor::AFloatingActor():
MovementMagnitude(0.0f)
{

}

Both ways do the same thing.