x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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)

Product Version: Not Selected
Tags:
more ▼

asked Aug 04 '14 at 06:26 AM in Blueprint Scripting

avatar image

The_E
11 1 2 5

avatar image Narghile Apr 11 '15 at 12:12 PM

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.

Narg

avatar image Narghile Apr 11 '15 at 12:30 PM

This is while I was developing it,

https://www.youtube.com/watch?v=QVkR2KCtdaI

avatar image Narghile Apr 11 '15 at 03:01 PM

This is a little closer to how I want it

https://youtu.be/8vCCvGYe43E

avatar image Singules Mar 02 '17 at 04:44 PM

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

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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:alt text

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: alt text

et voila, Turrets that respect the way they're mounted and rotate using their own local coordinate system.

more ▼

answered Aug 04 '14 at 07:45 PM

avatar image

The_E
11 1 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered Aug 04 '14 at 06:48 AM

avatar image

xC0DEB10C
303 12 117 40

avatar image The_E Aug 04 '14 at 07:17 AM

I got that far already (see here: https://www.youtube.com/watch?v=PJ8WP7LENJ0 ).

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 time). 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.

avatar image Jaydennh Apr 11 '15 at 11:02 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.alt text

turret aim.jpg (171.1 kB)
more ▼

answered Aug 04 '14 at 09:14 AM

avatar image

Alan Webster
860 50 34 81

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question