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"

Move a blank pawn with WASD C++

Hi,

I'm trying to move a pawn using the WASD keys. I am using the following code:

RDDPStrategyPawn.h

 UFUNCTION()
     void MoveUp(float Val);
 UFUNCTION()
     void MoveRight(float Val);

RDDPStrategyPawn.ccp

 void ARDDPStrategyPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)
 {
     Super::SetupPlayerInputComponent(InputComponent);
     InputComponent->BindAxis("MoveUp", this, &ARDDPStrategyPawn::MoveUp);
     InputComponent->BindAxis("MoveRight", this, &ARDDPStrategyPawn::MoveRight);
 
 }
 
 void ARDDPStrategyPawn::MoveUp(float Value)
 {
     if ((Controller != NULL) && (Value != 0.0f))
     {
         FRotator Rotation = Controller->GetControlRotation();
         const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::X);
         AddMovementInput(Direction, Value);
     }
 }
 
 void ARDDPStrategyPawn::MoveRight(float Value)
 {
     if ((Controller != NULL) && (Value != 0.0f))
     {
         const FRotator Rotation = Controller->GetControlRotation();
         const FVector Direction = FRotationMatrix(Rotation).GetScaledAxis(EAxis::Y);
         AddMovementInput(Direction, Value);
     }
 }

It compiles and runs just fine, and works perfectly on a Character-type pawn. However, movement controls do not work when applied to a blank pawn. Am I missing something obvious?

Regards, Rob

Product Version: Not Selected
Tags:
more ▼

asked Mar 29 '15 at 11:31 PM in C++ Programming

avatar image

Brokenarrow
1 2 3 4

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

1 answer: sort voted first

Ehm, if i'm not mistaken, the Pawn class in comparison with the Character class lacks the MovementComponent. That's why you can't move the Pawn. :X

more ▼

answered Mar 29 '15 at 11:51 PM

avatar image

eXi
6.8k 333 185 470

avatar image Brokenarrow Apr 02 '15 at 05:04 PM

Thanks for the reply, you are right. I figured out a workaround by using the Character Class.

avatar image eXi Apr 02 '15 at 07:06 PM

I'm glad i was able to help. I will mark this question as resolved. Feel free to reopen it if you have questions regarding this problem.

(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