I’m not sure if that line is valid, first time seeing it used that way, usually this how I would access the transform StaticMesh01->GetComponentTransform()
is “new scene” a mesh or a scene component.
I also don’t see a root component.
Where are you actually using your component to set it on the transform ?
I don’t see anything of the sort there. You also don’t call on actor location ?
You need to get location to transform to world either of your mesh or thru your component.
How are you going to store your possition to variable if you don’t have an actor location or a component location, or a mesh location, depending how you want to do this at what level, all work.
So what is it going to be your component location, you need to get that.
With that you get an Ftransform on it or an Fvector with location.
This I take it should get you the location, but you first need to get a location and then call on the function with a second line.
So first
a constant FVector or a ftransform Location variable = your component ->Get Component magical function from unreal docs ();
second
Transform to relative position or world
Variable location that you are going to use = Get magical function tha transforms (). type of function (here you insert variable from step one that is an fvector or an ftransform);
You are missing elements.
First line the function to get location for your component
Second line the function to transform your location that you have now from first line.
This is for transform and location is where, you have to have a location first ? where do you get the location in a variable, you have to get the location of the component, and since you don’t have a root component you also might get offsets on the component because it’s not rooted.
already sets the location while constructing the components, and later in the get transform function I want to read that all data in world transform and get it
You need to make the root component.
by the way where is the mesh attached to the component if that is the scene component there is no mesh, there is no mesh container ?
You have no mesh, just he container.
I am getting the location of the container and later set the mesh dynamically, Sir my approach is working fine in blueprints, I override the scene component in blueprints and add 4 static meshes and successfully gets their world transform and dynamically sets the meshes later when i need to that location contains a container.
So you are attaching to root your component but you don’t have the root component specified.
Then where is the mesh attached to the component in your constructor ? The mesh container ?
After this you need to get a location on one of them, on the actor, or on the component or on the mesh directly with GetLocation() function there many such functions depending how you want it.
Only after that you use that with a transform function to convert your possition that you got from step one.
Where are you using this class, is it placed on the map ? if it is remove it and add a new instance, sometimes it doesn’t refresh the class properly.
From your derived BP it looks good.
I would use SetupAttachment instead of AttachToComponent in constructor though.
You use your constructor helper.
Then after that you say
YourMeshContainer = Mesh name variable from constructor helepr.Object;
Your static mesh is now loaded inside the container and next step is to load the container on the component.
Your Component ->SetStaticMesh(YourMeshContainer);
This will set the container that has the mesh on your component.
After this you can call the possition of either the mesh directly, actor directly or component to get location, once you have a location on it you can use a transform function (I don’t recomand using ftransform)
So you can use a transform function with the variable you have from where you got the location.
It gives null because it should since there is no location to begin with.
I’m glad this is happening, BP user
C++ is a must.
After this you will get to the part where you have to get location on things, since it’s normal to first get a location on the possition where things are.