How to rotate a physics object until it is "looking" at a location

I’ve been going around in circles trying to figure this one out and I’m hoping someone might be kind enough to mock up and screenshot a node structure to give me some direction.

I am making a fixed camera top-down game where a player-controlled spaceship in the center of the screen will rotate to look at the mouse position. The spaceship is a static mesh with simulate physics enabled, so I understand this needs to be done by adding and subtracting angular velocity. The ship will only be rotating on the Z-axis (yaw) and its pitch and roll will be locked.

What would a blueprint node structure to achieve this look like (preferably with smoothing)?

Welcome to my life. Have a look here:

See if the above is useful at all. It depends on what level or precision is needed and how physically accurate we need to be. Do check @pezzott1’s post there as well. It’s a totally different approach that may as well work great for you.

2 Likes

Thanks! I did have a read of this post but couldn’t make much sense of it to apply to my use case. There are certain precalculations that he hasn’t shown the nodes for and I don’t know how those numbers factor in, so that’s what threw me the first time and left me stumped. I’ll have another sit down with it and try figure it out.

Hi @Eldaas, everything @Everynone says is pure gold. Here are a handful of other links that U may find useful:

How to calculate torque vector to rotate object in direction of certain rotation? - Development / Programming & Scripting - Epic Developer Community Forums (unrealengine.com)

and especially:

Add Torque to physics controlled player, to return roll to zero - Programming & Scripting / Blueprint - Epic Developer Community Forums (unrealengine.com)

The solutions would both need a bit of tweaking to apply to Ur specific use case, but it’s very achievable.