Align 2 components to have the opposite rotations and the same location (C++)
I'm trying to align 2 actors using two of their components but cannot seem to get them to align properly at all. I've gotten the rotation to work so that they are facing eachother but cannot get the math right to get their position the same.
I'm spawning two actors at 0, 0, 0 with a rotation of 0, 0, 0 and I want component A to be at the same location as component B but with an inversed rotation.
How can I simply achieve this? I've tried using FTransforms, setting locations using offsets and such but cannot get the math right, can anyone help? Here is my code:
As you can see, I've tried many equations but cannot find one that works. Any help would be greatly appreciated.
asked Feb 10 '15 at 06:02 PM in C++ Programming
I created a component and set it to the door's halfway point. I then did what I said in reply to Mike's comment:
If I get the world location of Room B's doorway and Room B's origin I should have B's offset and then be able to add the offset to Room A's doorway to get Room B's final position, right?
Once I had done that I tested it with multiple rotations and locations and all seem to be working so far. Thanks Mike for making me realise my error.
answered Feb 10 '15 at 07:07 PM
What behavior are you seeing?
I needed to align 2 actors on the same location with the opposite rotation for the purpose of then playing an animation on both that was synced, an attack and defend sequence. What was happening is the collision was preventing the location from being set correctly, if allowed a sweep on the set actor location it would be in a random point bumping up against the collision capsule. If I did not allow sweep, or tried to teleport the actor would disappear.
The solution for me was to turn off collision on the actor just before setting it to the same location of the other one. No math was needed for the location, and a simple inverse for the rotation only such as what you are doing.
answered Feb 10 '15 at 06:27 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here