Why span on a very large distance? C++, Blueprint

Hello. I write simple code for weapon mesh and bullet start, but when i spawn blueprint what extends of this class it’s spawn incorrect. On image it’s a small yellow border after text.

AWeapon::AWeapon()
{
 	
	PrimaryActorTick.bCanEverTick = true;
	USceneComponent *sceneComponent = CreateDefaultSubobject<USceneComponent>(TEXT("SceneRoot"));
	RootComponent = sceneComponent;
	BaseMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("BaseMesh"));
	BaseMesh->SetupAttachment(sceneComponent);
	bulletStart= CreateDefaultSubobject<USceneComponent>(TEXT("BulletStart"));
	bulletStart->SetupAttachment(BaseMesh);

}

what i do wrong?

Looks like the weapon is at a correct position, but not the mesh, select the “baseMesh” in the childrens, and see it’s position. you probably have some code to attach it, that would be a problem in that place ( wrong socket name or anything )
if you have some code moving “basemesh” or reattaching it, could you share it ?

Sometimes when the attachment of components takes place in your class Constructor the changes are not happening “in time”.

I’ve had a similar problem back in the days and I ended up using the following workaround:

  1. I created the attachment of my components in the constructor (just like you do)
  2. Then, inside the BeginPlay function I modified the location of the components to make sure that they were placed in the right location

So to sum up, try to modify your “bulletstart” component’s location inside the BeginPlay.

Thanks guys for help. I create weapon in blueprint. And it’s OK, but i want make it with C. Help with one other problem. I work on Unity before UE and now i have small problem with raycasts.alt text

Sometimes Vetcor of Hit result location qual is (0,0,0). Maybe something wrong with layers or with colliders? Help me please
286183-
][1]

and i see this every time for every chanel: Camera or so Visibility

you should add a if based on the “return value” of “GetHitResultUnderCursorbyChanel” meaning the result is valid ( if it has hit something or anything )