I’m using Hierarchical instanced static mesh component and my instanced mesh is set to Identity(). Now I’d like to add a vertical offset. But I don’t want to do that within the local space it’s transform currently is rotated to. I’d instead like to add in an offset to a prescribed vertical axis.
I tried using SetLocation() and it appears to move the asset along it’s local axis.
FTransform newTLM = newT;
newTLM.SetLocation(newTLM.GetLocation() / 2)
As a test I tried the above, and I would imagine this would get the location in world space, divide it in half, and set that new halfed world location as the location. Instead this appears to shift the asset along it’s X axis.
On the transform I see three things that can set. AddToTranslation, SetTranslation, and SetPosition. They all appear to set in local space. So how can I get the local offsets with a fvector in world space? I know that inverse transform will take the current FTransforms position/ rotation, a FVector, and apply the position/ rotation in reverse. I’m not sure I’m using it correctly though.
I used the getInstanceTransform to grab an instance I know was good, and wrote it out to the tempT transform then used it’s inverseTransformVector to convert the vector into local space, I was then able to apply that translation to my instance for the result I needed.
FTransform tempT;
Actor->Component->GetInstanceTransform(0, tempT, true);
newTLM.AddToTranslation(-tempT.InverseTransformVector(tempT.GetLocation()));