How do I set transform position of component in code c++

Hi all, another noob question.

I am making a USceneComponent and attaching it to the Mesh in my class inherited from ACharacter

myLookAtPoint = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("Lookat Point"));
myLookAtPoint->AttachParent = Mesh;

Next I want to set its default position to be in front of the character face. This is what I tried

//myLookAtPoint->RelativeLocation.X = -5;
//myLookAtPoint->RelativeLocation.Y = 5;
//myLookAtPoint->RelativeLocation.Z = 170;

//myLookAtPoint->RelativeRotation.Yaw = 90;

It did not work. This is how I checked.

As you can see in this view. I have a lookAtPoint made in the blueprint level so that I can adjust the the position.
However the myLookAtPoint that I made in code does not have any editable options.

All in all I just want to be able to make components and read their world location in c++ code. However I can’t even get the instantiation of components right, why is this so hard?!.

Hey TinyTeaTree

Don’t set the position in code. Attach it to a socket;
MyLookAtPoint->AttachTo(Mesh, “look_at_mount”);

Compile that, then go in to the mesh and make a socket called “look_at_mount”. You can use this tutorial, for example, to see how to do that;

You can then position the mesh exactly where you want it by hand, in the character BP. I’m not clear on the rest of your question- are you having problems finding the location of this component during run time?

I wrote that, compiled that, and my project died. It can’t even get up anymore. Disaster.

When you changed the code, where there references to it in the BP? Also, just noticed that you’re using a scenecomponent.

I have pretty much exactly the same thing, except its a custom static mesh. So, once I have compiled the code and set the socket etc, I go in to the bp and assign a mesh to it;

in the header;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = “Interaction”)
TSubobjectPtr FaceSensor;

in the cpp;
FaceSensor = PCIP.CreateDefaultSubobject(this, TEXT(“FaceSensor”));
FaceSensor->AttachTo(Mesh, “face_sensor_mount”);

Yeah its probably bad to attach a scenecomponent to a mesh. Comment out the code, recompile and the project should be back up and running. Then change the component to a static mesh component before recompiling and adding the socket etc. Btw, my code in the previous comment is wrong- the site has deleted the subobject type because its between angle brackets. Let me know how you get on.