C++ Code Doesn't Update Unless Instance gets replaced

My guess is that the .umap file stores the Transform information of your camera component, so even the default value had changed it was override by the value from the map.

Two possible fix:

Easy way (Not recommended): Set the camera rotation in BeginPlay().

  void AMyPawn::BeginPlay()
  {
      Super::BeginPlay();
      OurCamera->SetRelativeRotation(FRotator(-45.0f, 0.0f, 0.0f));
  }

Ideal way: Expose the camera component to Blueprint. Create a BP version of your pawn, and use the BP version in the map.

This way you can edit camera transform in the blueprint editor so it’s less hard-coded and compiling BP is much faster.

That fixed it, But is there a way that I can change the camera position via using some kind of variable in C++ and put UPROPERTY(EditAnywhere) on it?

In this case an additional variable feel redundant.

My second solution basically achieve the same thing. The code should look like this:

public: 
  UPROPERTY(EditAnywhere)
  UCameraComponent* OurCamera;

This expose the camera to the Blueprint. After compiling, create a BP version of the pawn and click “OurCamera” component. Now you can adjust the location and rotation at the “Transform” section. This is better workflow in larger projects because you can see the result in real-time.

What you entered in SetRelativeRotation() is just for default value.

So I was following this tutorial; Player Input and Pawns | Unreal Engine Documentation

and I just finished it up, but I wanted to change the camera rotation,So I went into the code and changed it and compiled on UE4.

But i noticed the camera rotation stayed the same and so I deleted the instance on the level and re-placed it in the level and now it was changed.

Is it how its supposed to happen? or Am I missing something?