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"

Tank gun stabilization

Hi there,

while creating a tank I`ve stucked on one issue - how to do gun stabilization effect similar to Battlefield or Call of Duty (barrel aims at one point in space, so its pitch varies depending on ground) in blueprints?

The best result was when I modified script from this tutorial, but it wasn`t perfect - the barrel constantly aimed at the center of screen. I`ve been trying with Line Trace Component, but without effect. I also experimented with Rinterp, but effects were similar to above (barrel aims right at my face :)

Thanks for any help, suggestions etc.

Product Version: UE 4.10
more ▼

asked Jan 04 '16 at 09:46 PM in Blueprint Scripting

avatar image

1 1 2

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

1 answer: sort voted first

I recently calculated hip tilt angle for standing on uneven terrain as part of my IK setup, I believe its a bit similar, so I will try to explain the simple trigonometry which I used, it works perfectly, but maybe there is a simpler way which I don't know of. Here it is in BP, (also sync required variable between character BP and animation BP if not doing trace in animation BP.)

Trace EventGraph AnimGraph

EDIT: You don't need to convert anything into vector for anim graph as in screenshot, only to rotator.

more ▼

answered Jan 05 '16 at 03:05 AM

avatar image

66 1 6 9

avatar image hidden11 Jan 05 '16 at 09:47 AM

Thanks for reply, it seems to work: for now barrel is stabilized, but constantly returns to base position from beginning - I think it`s not big deal to fix it.

BTW my tank turret and barrel are separate meshes (they will be replaceable).

avatar image Polivantage Jan 06 '16 at 09:23 PM

what do you mean with base position and the beginning, could you post a screenshot and I will have a crack at it?

If you mean, you want the stabilizing effect while being able to aim the barrel, I think there are a few ways of doing that, but what kind of balance do you want? because you could first use animation blends, like aim offsets, or you could use a complicated branch system with a lot of conditions, or you could change the base input values based on your aiming, what exactly do you want to achieve?

avatar image hidden11 Jan 07 '16 at 09:16 AM

I think this might clarify what I mean: as "Base position" I mean turret position in editor:

And this movie shows what happens when I try to move barrel up/down (camera is attached to socket in barrel)

base.jpg (35.9 kB)
avatar image Polivantage Jan 08 '16 at 08:56 PM

Ah I see, the barrel is basically always wanting to return to its position - its because it constantly interpolates the pitch it has to be at depending on the slope, - you could add your control rotation pitch to the pitch currently used to offset the barrel, that would float your barrel's desired pitch along with your mouse position, I believe effectively providing a way to aim and still neglecting the effect from slope. I am unsure how it would look in blueprints, perhaps you would need to compensate for the mouse aiming in some other way than just adding the pitch, I'm not quite sure.

here is how I calculate mouse pitch btw. mousepitch

(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