How do I set up a turret?
So, I am currently getting my feet wet with Unreal. The project I am working on is a re-implementation of this: https://www.youtube.com/watch?v=xz2T3U1DnKg
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)
asked Aug 04 '14 at 06:26 AM in Blueprint Scripting
Okay, so here's what I ended up doing.
Step 1: Get the direction to target in the turret base's/turret barrel's reference frame. This is accomplished through this function:
EDIT: Turns out I made a bit of a mistake here. Instead of the "Transform Direction" node, the "Inverse TRansform Direction" node must be used. Sorry!
Step 2: Take the results from that, and use it to determine the rotation of the element you want rotated:
et voila, Turrets that respect the way they're mounted and rotate using their own local coordinate system.
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++.
answered Aug 04 '14 at 06:48 AM
This took me a long time 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.
answered Aug 04 '14 at 09:14 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here