Placing Pawn in level bug with camera attachment

I really am not sure where the issue lies here. This particular problem actually stems from me trying to solve another problem I have (which I am still trying to figure out) that I will explain later. Currently though, with my pawn (base class in C++ with an overriding blueprint class which) when I try to place it in the level, (by drag and drop) the mesh and main part of the actor moves with my cursor but the camera always just sits as (0,0,0). See images for details:

Here is the actor in the blueprint view:

As you can see it has a camera boom which the camera is attached to with a mesh. Nothing very exciting or complicated… Now this issue only started occurring once I updated from 4.10 (I believe). Here is the C++ attachment code I am using:

	// Setup components
	Root = CreateDefaultSubobject<USceneComponent>( TEXT( "Root" ) );
	RootComponent = Root;
	CameraBoom = CreateDefaultSubobject<USpringArmComponent>( TEXT( "CameraBoom" ) );
	CameraBoom->SetupAttachment( Mesh );
	Camera = CreateDefaultSubobject<UCameraComponent>( TEXT( "FollowCamera" ) );
	Camera->SetupAttachment( CameraBoom, USpringArmComponent::SocketName );
	Mesh = CreateDefaultSubobject<UStaticMeshComponent>( TEXT( "Mesh" ) );
	Mesh->SetupAttachment( Root );
	Mesh->bMultiBodyOverlap = true;
	Mesh->bGenerateOverlapEvents = true;
	Mesh->SetCollisionEnabled( ECollisionEnabled::QueryAndPhysics );

I will also mention the main issue I am having right now, which I believe must be related: My game is a simple infinite runner style game with the pawn constantly moving forward (with player input for sideways movement). Strangely though since I updated from 4.10 (where everything worked as intended) the pawn now only has it’s flying code working (basic physics to make it hover) but something seems to be strangely broken with the forward movement. The function is definitely being called and is using the correct values, but in the editor the actor / mesh never moves forward. Even more strangely is that if I click on the actor after I run the game and eject from the pawn, it will show it’s position updating correctly and the RGB axis for moving the pawn will render really far away from where the mesh is (where I must assume the pawn should actually be). Very strange, not really sure what is going wrong. I can post any movement / pawn code if it will help diagnose this issue! Any help would be much appreciated! Thank you.

=/ any ideas?

Hello PantherNZ,

I have a few questions for you that will help narrow down what issue it is that you are experiencing.

Quick questions:

  1. Can you reproduce this issue in a clean project?
  2. If so,could you provide a detailed list of steps to reproduce this issue on our end?
  3. Could you provide screen shots of any other settings/blueprints/code that may be involved?
  4. Could you make sure that your code accounts for changes between engine versions?

Example of a change that has been made that may be related to the issue that you are having would be the attachment changes in 4.12.

“Instead of direct reads of USceneComponent::AttachParent, AttachSocketName, and AttachChildren you should use GetAttachParent, GetAttachSocketName, or GetAttachChildren. Direct writes should be replaced with SetupAttachment from constructors or AttachTo once components have been registered.”

Hello PantherNZ,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will follow up.

Thanks,

Updating the code to not directly use “USpringArmComponent::SocketName” works for the camera issue but I still have a problem where the actor doesn’t update visually.

See the location value as to what I mean. Strangely the code to make the pawn hover works correctly which uses “Mesh->AddForce( Thrust )” but the code to make it move forwards doesn’t: “AddActorWorldOffset( Forward * Delta )”

Were you able to reproduce this issue in a clean project?

I will try =\

Yes quite easily. It appears the core issue here is that I am trying to make a floating pawn. The way I had this working (before I updated) was the Pawn’s mesh was set to “simulate physics” and I had code to negate gravity and make it “float” with a hovering effect. Setting simulate physics to true though seems to completely break being able to call “addactorworldoffset” as well as move it in the editor etc. What is the correct approach for this?

I have provided a link to documentation that has information on physics in the engine. You will see a section for physics bodies (this section will have helpful information for what you are trying to accomplish). I have also provided a link to documentation on blueprints nodes that can be used when manipulating objects using physics. I hope that this information helps.

Docs: Physics in Unreal Engine | Unreal Engine 5.1 Documentation

BP_Docs: Physics | Unreal Engine Documentation

Make it a great day