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"

Correctly Creating and Auto-Possessing Pawn Blueprint from C++ Base-Class

Hello everyone, I'm trying to experiment a bit with the ue4 basics and started facing some odd behavior upon instancing a blueprint, that was derived from a c++ base class. The instanced ACameraPawn of the blueprint I created, does not get correctly possessed upon game start.

The short version: Why is the blueprint instance of my pawn not correctly possessed upon game start and why does it work for the c++ instance?

The long version: I created a c++ class derived from APawn, added a few movement functions as shown in online tutorials, and specified the following constructor:

 ACameraPawn::ACameraPawn()
 {
     PrimaryActorTick.bCanEverTick = true;
 
     USceneComponent* CursorComponent = CreateDefaultSubobject<USceneComponent>(TEXT("CursorComponent"));
     RootComponent = CursorComponent;
 
     CameraSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArm"));
     CameraSpringArm->AttachTo(RootComponent);
     CameraSpringArm->RelativeRotation = FRotator(-45.f, 0.f, 0.f);
     CameraSpringArm->TargetArmLength = 50.0f;
 
     UCameraComponent* Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
     Camera->AttachTo(CameraSpringArm, USpringArmComponent::SocketName);
 
     // Take control of the default player (I suspect something is not correct here).
     AutoPossessPlayer = EAutoReceiveInput::Player0;
     AutoReceiveInput = EAutoReceiveInput::Player0;
 }

If I now drop an instance of the ACameraPawn class into the viewport, it works as expected. Upon game start the Pawn gets possessed and he can be controlled through player input.

Now I create a blueprint based on the ACameraPawn. Without changing or doing anything else I drop an instance of the created blueprint into the viewport. But no matter how many times I press play, the camera gets centered to 0,0,0 and it's not possible to move the camera. Meaning the pawn changed his position and does not react to player input.

Oddly enough, if I hit play, select the camera pawn instance in the world outline, stop and then hit play again, the pawn gets possessed and can be controlled exactly the same way as if I dropped a c++ instance instead of the blueprint instance.

Product Version: UE 4.9
Tags:
more ▼

asked Oct 06 '15 at 03:26 PM in Blueprint Scripting

avatar image

Chartas
14 3 6 10

avatar image Vertex Soup Feb 05 '17 at 12:27 AM

Line AutoReceiveInput = EAutoReceiveInput::Player0; gives me this error in log: EnableInput can only be specified on a Pawn for its Controller

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

0 answers: sort voted first
Be the first one to answer this question
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