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 wasnt perfect - the barrel constantly aimed at the center of screen. Ive 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
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.)
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).
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?
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.