Pawn with Movement Component will only move if Root is StaticMesh, not SceneComponent

I have been creating a custom pawn with a custom movement component - the movement component does work as I have worked through and overridden the necessary functions. The issue comes in when trying to apply movement to the Pawn’s Root as a Scene Component. Here is the relevant part of my constructor:

MySceneRoot = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
	SetRootComponent(MySceneRoot);
	MySceneRoot->SetMobility(EComponentMobility::Movable);
	MySceneRoot->Mobility = EComponentMobility::Movable;

MyMovementComponent = CreateDefaultSubobject<UPawnMovementComponent, UCustomPawnMovementComponent>(TEXT("MovementComponent"));

	MyMovementComponent->UpdatedComponent = MySceneRoot;

MyMeshComponent = CreateOptionalDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComponent"));
MyMeshComponent->SetupAttachment(MySceneRoot);

What I have worked out is:

  • My SceneComponent as root is indeed movable; I tested by adding location per tick and that moved fine.
  • If I modify the above code so that MyStaticMesh is the Root, and set MyStaticMesh as the UpdatedComponent, then the pawn moves.
  • I’m aware that “MySceneRoot” basically just shadows Actor’s “SceneComponent” which already exists, but I have tried with both and no improvement.
  • The Pawn even updates its rotation to match the movement it should be going in; it just doesn’t move.

The movement is applied to the pawn via SimpleMoveToLocation which used Nav Path finding, this does indeed work when the Static Mesh is the root component.

I looked into DefaultPawn class for inspiration, i notice they use a CollisionComponent as the root. When I copied this, it does work. But I am reluctant to use either Mesh or Collision as my root as I need to be able to move those around to reposition meshes, which is why I want to use SceneComponent. When I have the CollisionComponent as root, I cannot rotate and position to match the mesh (see pic). And Actually I want to use the mesh’s simple collision instead of adding another component.
image

Is SceneComponent just not compatible to be operated by a MovementComponent? Do I need to set any other properties?

Thanks!

1 Like