• News

• Industries

• Learning & Support

• Community

• Marketplace

# Matching rotation on 2 static meshes when one simulates physics. Help needed :)

Hi folks, really been banging my head against a wall with this one. I’m working in blueprint and have an issue matching the rotation of one mesh to another. So…

Edit - TLDR - i’m trying to get one physical mesh to match another meshes location and rotation using linear and angular velocity in blueprint. My second post below is now partially working but not quite…

I have a static mesh (A) It’s a child to a motion controller, no collision, no gravity, no physics. It moves when the controller moves. Works great.

I have another, separate static mesh, (B) no gravity, set to collide with everything, is simulating physics.

I want B to always try and match A. Even if B becomes obstructed by something, when it becomes unobstructed, I want it to snap to A and match it’s location and rotation.

Now… I’ve got location matching working by measuring the location offset between A and B, and working from that vector i’m driving a “Set All Physics Linear Velocity” node to move B toward A. This works. HOWEVER, I have no idea how do do this for rotation. I need to use (I assume) “Set physics angular velocity” But I have no idea how I can work out the velocity necessary to get them to match. How can I determine the linear velocity needed to match the rotation of B to A, when all I have to work with are rots?

I hope that made sense, any help would be much appreciated. I have a feeling I may need quats for this, but am open to any suggestions!

Thanks folks.

Ok, I have this partially working. TLDR of my 1st post,** i’m trying to get one physical mesh to match another meshes location and rotation using linear and angular velocity in blueprint.**

Location is working fine, am using this logic to set the rotation:

Trouble is, the mesh, although it seems to be orienting correctly, keeps spinning clockwise. I believe it’s because I need to work out whether the mesh should rotate clockwise, or counter clockwise and then change the angular velocity accordingly.

Question is, how do I work that out? Looking at the dot product of the 2 forward vectors doesn’t seem to help as the output can be both positive and negative, irrespective of how the mesh should be moving (anywhere from -1 to 1)

I’ve found this explanation online which details, I think, how I could solve it. But it’s in code, and lost me in terms of how it was working…
http://www.gamedev.net/topic/294627-vector-rotation-and-dot-product-question/

I’m really banging my head against a wall here, any help would be really, really appreciated. Thanks a lot for reading this far, even if you cant help

Thanks folks.