Why is my Custom Pawn unable to be controlled or moved?

Hello,

I’m new to UE4 and I’m trying to work on a game like “Arkanoid” with Blueprints, because I thought that wouldn’t be too hard for the start.

Well, I was wrong …

I can’t even make my custom pawn blueprint (NOT character BP, for I don’t have a skeleton mesh but a simple bar - the “Pillar” static mesh from the standard content as the player) “MyPawn” to be controllable or moving.

I decided to take the Side Scroller Blueprint template to start with. In the world settings, I changed the “Default Pawn Class” to “MyPawn”, after changing “Game Mode” to “MyGame”.
For the Eventgraph, I copied the “InputAxis MoveRight”-Event-Node as well as the “Add Movement Input”-Node fom MyCharacter", since that is the part that is responsible for the movement, I thought.

I noticed, there is a “NativeCharacterMovement” component in the Components of “MyCharacter”, so I decided to copy/paste it into “MyPawn”, but that didn’t seem to make any difference …

When Debugging the Blueprint “MyPawn”, I can see a constant flow from InputAxis MoveRight to Add Movement Input, but the pillar doesn’t move, when pressing A or D.
When I hit “Play”, my Pillar appears at the “PlayerStart” mark, but nothing else happens.

The official documentation didn’t help me and I was googling for days to find anyone who had shown or explained clearly how to make a custom pawn controlled by the player.

The next problem I ran into is, how to make a cameraActor the “Main” camera for the level, because I want to have a single, not moveable camera. The templates from ue4 don’t cover that and I didn’t find an example yet, where there’s a fixed camera at a single point from the beginning.

Can someone help me?

Thank you!

Here are some pics for more information

9424-gamemode.png

9425-mypawncomponents.png

9426-mypawneventgraph.png

I assume MyPawn inherits directly from Pawn. If so, you can’t use a CharacterMovementComponent, as it works specifically with Characters. (Trying to copy-paste the CharacterMovementComponent from MyCharacter to MyPawn actually crashes my editor.) Using blueprints, the only built-in MovementComponent options you have when inheriting directly from Pawn are ProjectileMovement and RotatingMovement. Unfortunately neither fits your needs.

Assuming you don’t want to use code, I can think of two options that might work for you if you want your paddle to be a pawn:

  1. Derive MyPawn from DefaultPawn instead of Pawn (you will need to look under “Custom Classes” for DefaultPawn when creating the blueprint) and use the same MoveRight event graph as you have above. DefaultPawn will give you a MeshComponent, CollisionComponent and FloatingPawnMovementComponent, all of which should work well for your paddle.

  2. Derive MyPawn from Pawn, and drive movement without a MovementComponent by setting the pawn’s location directly using a SetActorLocation node. The following is an example:

9444-pawnmovedirect.png

To set a fixed camera as your view of the play area in either of the above cases, you could place a CameraActor in your map and set it as the view target like so in your level blueprint:

9445-setviewtarget.png

Another option altogether is for your paddle blueprint to not be a pawn, but just a regular actor. In this case you could define the movement bindings to move your paddle actor on a PlayerController blueprint. Furthermore, you could set your view target to a SpectatorPawn. You would create a blueprint that inherits from SpectatorPawn and set the class as your default pawn in your GameMode. In your case you’d also want to disable the default input bindings that SpectatorPawn adds by unchecking “Add Default Movement Bindings” in the blueprint’s defaults.

Thank you so much for your help! I got the camera exactly the way I want it! But still I got trouble with my pawn - even though I can move it now, which is great!
I had to choose between DefaultPawn and Pawn. When choosing Pawn (with “SetActorLocalOffset”), I’m running into problems when it comes to collision.

DefaultPawn has a CollisionComponent, so collision generally works, but the shape of the Component is a sphere, which doesn’t fit my player’s paddle.

Is there any chance to change the shape of the collision component (into box or capsule, e.g.)?

Thanks a lot!

As far as I know, you can’t change the shape of the collision component of a DefaultPawn using only Blueprint. You’ll probably have to go with inheriting your blueprint class from Pawn. As you point out, there is no default collision component. But you can create one!

Using Pawn as your base for your blueprint class, go to the Components tab. In the Add Component drop down, select Box under Shapes. With the Box as your RootComponent, I would then add the StaticMeshComponent as a child. As for defining your collision behavior first you’d want to size/position the box to match the shape of your paddle mesh. Next, edit the properties of the BoxComponent to define your collision behavior, possibly using one of the presets. (If the DefaultPawn collision behavior was fine other than the shape, I’d select the Pawn preset.) Finally, set the collision preset for your StaticMeshComponent to NoCollision, since you are already driving collision from the BoxComponent.

Here is a screenshot that might help you (I scaled both the BoxComponent and the Cube StaticMeshComponent to match each other and look like a paddle):

ehm … sorry for my question, it may sound really silly, but how did you change the scale/position of the box?
When it’s the root, it’s not changeable at all. So I tried to add it as a child of the mesh and change the scale to match the paddle, but when I then define it to be the root, all scaling is gone.

I’ve been googling that problem and found actually no way to get a component like you showed in your picture. It says, there has to be another root (SceneRoot, or an arrow, e.g.) to make everything else changeable, but that’s not, what you showed me, so I’m really confused…

Again, excuse me for being that helpless and thank you so much for your support …

Hello and thank you for not writing me off just yet! :slight_smile:

But … ehm … sorry for my question, it may sound really silly, but how did you change the scale/position of the box? When it’s the root, it’s not changeable at all. So I tried to add it as a child of the mesh and change the scale to match the paddle, but when I then define it to be the root, all scaling is gone.

I’ve been googling that problem and found actually no way to get a component like you showed in your picture. It says, there has to be another root (SceneRoot, or an arrow, e.g.) to make everything else changeable, but that’s not, what you showed me, so I’m really confused…
Again, excuse me for being that helpless and thank you so much for your support …

In the screenshot above I set the BoxComponent size by setting the Box Extent to [128, 32, 16] (found under the Shape category when the component is selected). The StaticMesh I used was /Engine/EngineMeshes/Cube, which is 256x256x256. To match the collision component, I set the Scale of the mesh to [1.0, 0.25, 0.125]. I’m a relatively new user of Unreal, so maybe I’m not showing you the preferred way, but the above worked for me in prototyping my own WIP 2D game. (I eventually replace any explicit collision components created within the editor with static mesh assets that include custom convex collision primitives.)

@morvister Please mark this as the solution

Awesome! It works now! Thank you so much!