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"

Possess a pawn and use static camera?

Hello, I am attempting to do two things: 1) Control a Pawn that can fly around, and 2) Look through a camera not associated with that pawn (static camera).

I've looked all over, couldn't find anything, I know there are other questions like this one, please help, etc. etc... I think it's because I'm using C++. My problems are:

1) The pawn in question won't possess the moment I hit the "play" button, even though it is set to "Default Player Start."

2) When I click "possess" I can control the pawn, but the viewport shows it as if it was a first-person view from the pawn, NOT the static camera.

What am I missing? And how, if possible, do I change it with C++?

Product Version: UE 4.15
Tags:
more ▼

asked May 14 '17 at 03:22 PM in C++ Programming

avatar image

Borkleby
36 4 11 13

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

1 answer: sort voted first

In UE4 pawn possessing and view targeting are 2 separate mechanisms, but by default for easiness, player controller set possessed pawn as view target in same time. You can disable that by setting this variable in PlayerController to false:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/APlayerController/bAutoManageActiveCameraTarget/index.html

This variable is also binded in blueprints and you can set it there too. After that you posses and set camera sepretly, you set view target using this function (which is also in blueprint)

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/APlayerController/SetViewTarget/index.html

Now here C++ exclusive feature, view target is a actor which camera manager asks about camera position ("From what position you want to be viewed?") by calling ClacCamera function:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/CalcCamera/index.html

Default code in AActor class picks position of first active camera component in actor (so in blueprints you can control camera by activating and disableing camera components), you can change this behavior (and don't use camera components at all) by overriding this function in actor that you gonna set as view target.

more ▼

answered May 14 '17 at 03:54 PM

avatar image

Shadowriver
35.9k 929 169 1105

avatar image Borkleby May 14 '17 at 04:09 PM

In which file(s) would I write this code?

avatar image Shadowriver May 14 '17 at 06:07 PM

What do you mean? You mean CameraCalc, you can override it in any actor class

avatar image Borkleby May 14 '17 at 06:09 PM

I mean, where do I write the code? Which specific .h or .cpp files?

avatar image Shadowriver May 14 '17 at 07:23 PM

Huh? Do you know basics of C++? first 2 links are variable and function in PlayerController, so you can call them anywhere you can access PlayerController, the last one is a virtual AActor function which you can override to change behavior of the actor, this function is called by camera system to asking how camera should be positioned.

I didn't notice your auto possessing issue, i assume you set default pawn? you don't need to do it in C++, just set in project serrings. If you don't set default pawn and you just place pawn manually in editor then you code need to possess that pawn.

(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