There is only scale option in transform options

I created a UShpereComponent in CPP and did nothing else

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Collision, meta = (AllowPrivateAccess = "true"))
	TObjectPtr<USphereComponent> EnemyDetectCollision;
	EnemyDetectCollision = CreateDefaultSubobject<USphereComponent>(TEXT("EnemyDetectCollision"));

Then I created a BP inherited from this class, and found no location and rotation options in the details of the sphere component.
When I start the game and move the character, the sphere component attached to the character didn’t move, stayed at the orignal place.
I tried to set relative location of the sphere component in the cpp, but it didn’t work.
Here is the Screenshot of blueprint.

I reboot the UE5 engine and everything works.
Problem is solved, but I still don’t know why.
When should I reboot the UE5 engine to compile the code?
If I reboot every time after modifying the code, it may consume lots of time.

In your constructor, after CreateSubObject you should attach the component to another component

You can do that simply by calling

EnemyDetectCollision->SetupAttachment(RootComponent)

Which will attach it to the capsule and it should work as expected

1 Like

Thanks for your reply.
The component created in cpp is attached to root component by default, as shown in the blueprint screenshot.
I initially attempted to manually attach the component to the root component in C++, but it didn’t work until I restarted the engine. . After rebooting, the component functions correctly even without manual attachment.
Unfortunately, I’m now unable to reproduce the issue now. While rebooting seems to resolve many problems, the underlying cause remains unclear.