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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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

And this is the part of the blueprint that is specifically for the pitch of the gun (as a whole and then zoomed in) alt text alt text alt text

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!

Product Version: UE 4.8
more ▼

asked Jan 08 '16 at 09:08 PM in Blueprint Scripting

avatar image

3 2 2

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

4 answers: sort voted first

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

alt text

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.

sentry.png (344.2 kB)
more ▼

answered Jan 10 '16 at 06:58 PM

avatar image

1.5k 65 132 103

avatar image Jade-S Jan 10 '16 at 07:08 PM

Thank you for your explanation. Now that it's been explained to me I understand where I went wrong. I will apply this logic to my version and I hope that it will now work!

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

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

rotateeyes.png (290.8 kB)
more ▼

answered Jan 08 '16 at 09:44 PM

avatar image

66 1 6 9

avatar image Jade-S Jan 08 '16 at 11:27 PM

After reading your reply I have been trying to experiment with this area of the blueprint and plugging the pitch into the roll etc. but I have not yet come across anything that has fixed the way that this area of my model rotates. Thank you for the suggestion though!

avatar image Polivantage Jan 09 '16 at 04:58 PM

How exactly doesn't the pitch do what you desire, what does it do if anything at all? you can try play with multiplications by -1 to reverse values and + or - 90 or some other value of degrees to see what's going on, in other words if you introduce a controlled change, you could figure out what's happening. Also if your yaw works proper, could you just duplicate the logic for the pitch?

If nothing works I'd be intrigued to take a closer look at it and try find a solution. If you don't mind sharing the project, you could strip it of any bulky content (like all the textures, or something, so its reasonable in size) and upload somewhere like google drive, with a link here, also if you decide to do that, you could delete the saved and intermediate folders from the stripped project since I think those have to be regenerated anyhow. If the whole project is below a gig I'll be fine fetching it.

avatar image Jade-S Jan 09 '16 at 07:40 PM

The pitch currently just floats forwards and backwards instead of rotating on it's pivot point and firing at the player. I have tried to show it in this diagram.

alt text

I have tried to apply the way that the yaw works to the pitch however seeing as I am not the one who created this blueprint and the fact my knowledge of blueprints is fairly limited I haven't really had any success in this.

If you wouldn't mind having a closer look at my blueprints that would be greatly appreciated. I will try and reduce the file size of the project and upload it to google drive now. Unfortunately my internet upload speed isn't great but I will post the link to it as soon as it is complete.

dghhgfg.png (860.6 kB)
avatar image Jade-S Jan 09 '16 at 08:11 PM

It might be worth me mentioning that I want the barrel and the pitch to rotate in exactly the same way together. They are only seperate for the purpose of the projectile spawning as that is where the socket is located. Also, I am currently working in version 4.8.3. The link to the project is below:



avatar image vanlacke Jan 10 '16 at 11:59 AM

Is this what you're trying to do? https://www.youtube.com/watch?v=QvuGo5gz3rE&feature=youtu.be

I'll admit I didn't want to read everything posted here, so just making sure

avatar image Jade-S Jan 10 '16 at 06:24 PM

Yes that is exactly what I am trying to get it to do! How did you get it to do that? The only problem I can see with it from that video there is that the barrel still drops down when aiming at the player instead of staying in the point where it should be fixed. If you could either explain your solution so far to me or send me the files I would be very grateful as so far I have only managed to half solve the problem.

avatar image vanlacke Jan 10 '16 at 06:50 PM

Not sure what you mean about the barrel. Do you mean it isn't clamped? I removed that, but can be easily added back in. I'll post an answer with a short explanation, very simple

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

Dear Jade,

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.

more ▼

answered Jan 10 '16 at 03:35 AM

avatar image

66 1 6 9

avatar image Jade-S Jan 10 '16 at 04:30 AM

Thanks a lot for the reply. The pivot points are definitely what seemed to be causing the problems so I understand where you are coming from.

As far as I am aware the pivot point for the barrel/pitch should be in the same place as in the picture I sent. I'm not entirely sure how to do the things you've just explained because I'm not that experienced with UE4 but I do understand what the problem seems to be. I have been trying to follow along with what you were saying in the file I have here but haven't seemed to have fixed it yet.

I hope that the third option you suggested does fix the problem. Please let me know if you need any additional files or have any other questions about it. Thank you for your time!

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

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:

  • have set up fake pivot points, by parenting gun parts to some invisible boxes, solved about half the problem, mainly that the gun doesn't slide anymore and remains in place during rotation of the base.

  • have tried all three approaches, unfortunately I'm obviously really bad at math or something, because I couldn't get it done. I became a lot wiser though, here is some stuff I tried to implement, but didn't understand half of it, perhaps you will be able to solve it with some hard maths? I certainly can't.

  • Currently the gun pitch actually works, in place and stays between the clamped values, but for some reason which I couldn't figure out it only works if you stand on a certain side of it, like 180 degrees oriented to the world. And that is very strange because I'm actually only applying relative rotation, not world rotation in this edit.

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

more ▼

answered Jan 10 '16 at 05:40 AM

avatar image

66 1 6 9

avatar image Polivantage Jan 10 '16 at 05:53 AM

the last thing left to do is to get the barrel to change pitch under any yaw of the base which is its parent, not just when its facing north, the rest works pretty good.

avatar image Jade-S Jan 10 '16 at 06:17 PM

Thank you ever so much for you help. I feel like my sentry gun is well on the way to working now and I have learnt quite a bit from your explanations of how it could be fixed. The mathematical side to it is really interesting and I shall definitely be looking more into that. I have been looking at it in engine and I still haven't figured out how to get the pitch to work when going all around the sentry but I think I should be able to do it. I am going to try out some of your other suggestions for it.

I think I can take the rest from here but again, thank you for taking the time with my sentry gun to make it work better and to explain it all to me!

(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