Now, in order to get that right, I obviously need to set up my models correctly. This includes the turret setup. Now, FreeSpace models can have multipart turrets (i. e. Turrets with separate bodies and barrels) mounted at arbitrary angles on a given ship.
My question is, how do I set up the Blueprint script to rotate said bodies around their pivot axes?
(Turrets are mounted on the base ship model using Sockets, if that helps)
First you need an accessor to the mesh which is probably a sub component of your actor. To make it point into the correct direction, at least for a straight aim without any delay, get the vector from your turret to the target and use that to create a rotation, which can be added or set to the world or local rotation/translation of the sub component.
For detailed instructions for each step use google/answerhub/forum/wiki, for example: how to get actor mesh component in blueprint/c++.
And to tell you the truth, all this would be much easier/cleaner/shorter if you did it in c++.
Mathematically, what I think I need to do is to get the lookat direction from the turret base to the target in the turret’s local coordinate system, and then rotate the turret base around its “up” vector (whatever it may be at the ). If this is only possible in C++, or if I have to write C++ functions to get there, so be it, but I’d rather do everything I can do in Blueprint in Blueprint.
This took me a long to get right, i am controlling the bone of an arm which would be your turret. the debug line is temporary. hope this helps, let me know.
“With the help of this tutorial, you will be able to animate turrets in UE4, which are always tracking the target correctly, regardless of their own orientation.”