Adjusting a blueprint for a sentry gun so that it rotates in the correct places
I have been given a blueprint for a sentry gun to apply to my own model. However in this blueprint I believe that the yaw and the pitch of the gun are both set up to pivot from the same point.
The problem is that I want the barrel of my gun to rotate from a separate point. How can I adjust the blueprint so that the barrel of my gun rotates on the pitch correctly? At the moment it just sort of floats forwards.
Here is a diagram of where I want the gun to rotate. It works fine rotating on the yaw and tracking the player, the only problem is with the pitch.
And this is the part of the blueprint that is specifically for the pitch of the gun (as a whole and then zoomed in)
If you need to see any more parts of the blueprint or need any more information please let me know. This is my first attempt at working with blueprints so my understanding of them isn't great.
Any help would be greatly appreciated!
asked Jan 08 '16 at 09:08 PM in Blueprint Scripting
Biggest problem: Mesh transforms are very bad for this situation. I assume you built the model and simply exported everything in place? What you should generally always do it make sure everything is centered, scaled, and rotated correctly. Here's a short vid to explain: https://www.youtube.com/watch?v=UlkbhJYeRyE&feature=youtu.be
Another issue is you're changing the rotation of the pitch thing unnecessarily. Simply attaching it to the barrel (or vice versa) would work find to rotate both. Also, and this is just personally, the blueprint nodes are far too spaced. I had to rearrange and bring everything closer to not have to scroll so far
Some notes: Barrel is attached to socket in the yaw piece do get rotation (you may not want this, but I found it made more sense to not allow the barrel to rotate yaw at all). Pitch thing is attached to barrel. If barrel rotates, so does the pitch thing.
answered Jan 10 '16 at 06:58 PM
Dear Jade, When things tend to get complex a good structure always helps see things more clearly, yet from a brief look at it, I can't see the reason for subtracting "barrel length" from the pitch. Also here is the blueprint which rotates my characters eyes, including pitch, towards the camera, correctly. Notice that my pitch is plugged into Roll. I've no idea why, but it works like this and I hope it will help you as well.
answered Jan 08 '16 at 09:44 PM
As I opened the blueprint it became immediately clear where the problem is, or at least its my first insight which I wanted to share before I continue to try things out which are described below also.
Basically it looks like a pivot point problem after all, the yaw works correctly because the pivot point is in the low centre of the model, thus it is also in the centre of rotation for the yaw. But the pivot point of the gun_pitch is in the exact same place, so to rotate it correctly one would have to take into account the offset which occurs, because the pivot point is actually below the turret. In fact, all the pivot points are in the same place,
is this also the case with your BP? Since in the picture you provided last, the pivot point for the gun_pitch is drawn correctly, yet its not what I observe in the blueprint.
It would seem that I now have two ways to proceed - either make a simple copy of the mesh with correctly placed pivot points to illustrate that the logic is correct (after I test it of course), or I could try and mitigate the offset created by the unhandy placement of the pivot point for the gun_pitch.
However, there is a third option which I believe is the easy solution for all this since it wouldn't require me to build a mesh and wouldn't require you to re-export your assets - add the gun_pitch part of the mesh to a new (invisible) actor inside the blueprint, like a box (just like the scene root of the BP), so the pivot point can be changed.
Ideally you would want to re-export your mesh with correct pivot point placement, because then you wouldn't have an extra actor in your BP scene (like an extra, empty box), but just to solve this on my end I will go with this third option for now. Also if you originally exported the model with pivot points aligned in one place to easily place it in your scene, I believe its not really necessary because you only have to align it once in your blueprint and from there on you just re-use the blueprint in the level, not the separate meshes. I tend to only align pivot points of static structures which consist of many parts, all rotating and moving parts need the pivot points thought of as separate items and so on.
To summarize- if the gun_pitch is within the structure of another object, like an invisible box I'm about to add, you could just rotate that instead of the gun_pitch itself. I will test this and post the result, but my suspicion is that you know what I mean and are already on your way solving this yourself, I'll report back as I test this method as it really beats the other two in terms of time and effort since I don't have the source model files, also it will allow to test the logic.
The bottom line is that whatever can come of the result I linked below will not be optimal solution for this.
But honestly there has to be a simple solution for this, I wish someone with more knowledge would advise as I've still got a lot to learn and this is one of those things.
this is what I came up with so far, it was a rough night, made some progress, but I think the sentry gun won anyway:
I thought of another approach which would require placing bones in the turret, just 2 or 3, a very simple skeleton, for very simple animation from the animation graph - per bone blend. Might be worth a try, if you would like to explore that I wouldn't mind spending more time with your sentry gun.
we already went through a lot of cool stuff together:
Side notes for whoever dwells into the math corner:
distance between barrels = 80units, Circumference 251.33 Radius 40 (arclength=?)
2 . Pi . 40 . (X/360)= 251.33
x =radians - convert to angle for roll rotation, couldn't get arc length right..
answered Jan 10 '16 at 05:40 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here