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"

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

So I was following this tutorial; https://docs.unrealengine.com/latest/INT/Programming/Tutorials/PlayerInput/index.html

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?

Product Version: UE 4.15
Tags:
more ▼

asked Jul 11 '17 at 11:11 PM in C++ Programming

avatar image

dogu189
33 12 15 23

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

1 answer: sort voted first

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.

more ▼

answered Jul 12 '17 at 12:40 AM

avatar image

madturtleGGinin
346 1 5 4

avatar image dogu189 Jul 12 '17 at 09:12 AM

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?

avatar image madturtleGGinin Jul 12 '17 at 06:41 PM

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.

(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