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: Blue Planet 2 War in Heaven PC Gameplay The Blade Itself - YouTube

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++.

I got that far already (see here: Turret base tracking behaviour - YouTube ).

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.

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.

Hi, I’m having trouble with this, could you provide a little more help with this please?

I have created a turret, I made the Turret a Pawn and added sensing to it, so if it sees or hear you it will rotate and try to shoot.

The code if fairly long and would take a few screen shots. If you want it, I will post it up.

This is while I was developing it,

https

This is a little closer to how I want it

Hi here is another interesting tutorial [www.vaduunlabs.com/index.php/en/tutorials/29-adv-turret-animation][1].

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.

http://www.vaduunlabs.com/index.php/en/tutorials/29-adv-turret-animation