Hello all! I am working on a system for my game that takes modules that I create and snaps them to each other using attachment points. Here is some information about this. I didn’t get any replies here so I took my question over to the GameDev forums and thankfully got a reply. Now I am having trouble calculating the transform correctly. I’ve tried calculating it in the order that he told me to, but it still doesn’t work correctly especially when the module that the new module is being attached to is rotated. Here is what he told me to do:
Tm1 = Tm2 * Ta2 * Ta1_Rotation * inv(Ta1_Translation)
And here is what I have now:
// ThisAttachmentPoint = Ta1 // OtherAttachmentPoint = Ta2 // OtherModule = Tm2 FTransform NewTransform = OtherModule->GetTransform(); NewTransform *= OtherAttachmentPoint->GetRelativeTransform(); NewTransform *= ThisAttachmentPoint->GetRelativeTransform().GetRotation(); NewTransform *= FTransform(ThisAttachmentPoint->GetRelativeTransform().GetLocation()).Inverse(); SetActorTransform(NewTransform);
Does anyone see anything wrong with this or have an idea of why it may not be working? Thanks!