Custom Pawn Movement Component

Hello,

I have a default pawn that is basically a box component driven by physics and I want to be able to control it’s motion via player inputs.

I have successfully implemented the new default pawn, however I don’t fully understand the best way to control it. Ideally I want to be able to update it’s velocity based on player inputs, Do I have to implement a custom Movement component, and if so how do I do that!

Any help reality appreciated.

Thanks

#Custom Character Movement Comp

I have a wiki tutorial on this exact subject here:

this is for making your own C++ custom character movement class and overriding any virtual functions of the base class that you want!

Rama

I think the easiest way should be doing it the way it is done by default:

Add a PawnMovementComponent and create a function “AddInput” or something where you call the “AddInputVector” function of the PawnMovementComponent:

virtual void AddInputVector(FVector WorldVector, bool bForce = false);

Thank you, exactly what I was looking for!

Hi Rama I am following your C++ custom character movement tutorial that you linked and I can’t quite get things working correctly. I added the custom movement component class and followed your tutorial exactly. Everything compiles fine but when I run the game in the editor I hit a breakpoint seemingly being caused by my Character’s reference to CharacterMovement being NULL. I also noticed that his base movement component is also NULL. I was wondering if maybe there was a change to UE 4.2 that may have caused this to happen (I know they altered a few things in CharacterMovementComponent) or if you knew anything about this. (It is also very possible that I just screwed something up).

Hi Rama, i can confirm what Alryco wrote - did implement your tutorial but only get a nullptr when trying to “Cast< UMyMovementComponent >( CharacterMovement )”;

I’ve been looking at this well and I kept making noise on the forum. Eventually someone told me that in 4.2 you have to delete + recreate the pawn. I’ve updated Rama’s wiki instructions.

The person that informed me said there was a fix in github so hopefully wont need these extra steps in 4.3

I can confirm this as well as happening in 4.2

It is a huge problem!

I dont know what to do about it :slight_smile:

Rama

Delete + recreate the character or wait for 4.3. I’ve updated the wiki.

#Robert M. Fixed this here

Link to github to implement fix locally while not yet up to 4.3 / whenever his change is fully brought into the engine.

https://github.com/EpicGames/UnrealEngine/commit/fab71f76b717a9bafbb0b91831ebb44cd73f0f11
Rama

Hey Rama I can’t seem to find a way to private message you on here so I’m just posting this here in hopes that you’ll see it. How do go about replicating a player/AI controlled pawn/pawn’s movement? There are a ton of articles about character replication that depend so much on the character movement component that they aren’t applicable to pawns for someone still learning and the character movement component itself is so restricting if you’re not doing a humanoid for a shooter/platform it seems. Any help would be so appreciated.