Aiming a Gun?

I’m trying to make a rig so that I can accurately point a gun at a target, except that I can’t seem to figure out what the **** is going on. I’ve tried using the track to constraint, but it doesn’t seem to work. Any suggestions?

Are you certain that the “center” of the gun-object (and of the target) are where you expect them to be? Have you “applied size and rotation” (thus resetting these parameters to zero)?

The clue will be found in exactly how the objects “misbehave.” There could be any number of reasons… but remember, Blender thinks it is following your instructions.

I’ve managed to fix it. I still need to do some tweaking to get it to work with the hand correctly, but I figured out what’s wrong. Turns out that I didn’t orientate the items properly when I set it up.

I thought I got it working, but for whatever reason, the stupid thing is twisting (moving the target higher on the z, it rotates on the y), and a limit rotation constraint doesn’t seem to be working. Any suggestions?

You’re sure you’ve got the axes setup right? I usually end up using y and -z.

I am using y and z, and they are set up right, it’s just that the object is twisting. It’s fine in the rest position, but moving the target from there results in the gun twisting on the y axis, excuse me, it doesn’t even aim right then.

This is the kind of problem where lots of people know the answer but would find it hard to scream out because there is so much X-Y-Z variation which could be applied differently… especially when sometimes Z should be “up” other times it might be Y or X.
Suggest you delete non essential parts of your work and post the result here fore people to look at properly.

Also, if you’ve moved (animated) the rotation of the gun, then added a track, it’s going to screw things up.

Okay, here’s the file, I removed everything except the camera, a light, and the objects in question. I’ve also removed most of the armature, if you want the whole armature, I can put it back in.


HELP.blend (45.5 KB)

Well in the mean time, I’m rigging a tank, and so far I’m having no problem getting it to move the way I want it to. I’ll try to see if I can at least get that to track properly, but only to see if it works correctly. And on that note, would I’d be able to do a locked track and adjust the windage from there without anything going psychotic?

I’m not sure exactly what was wrong with your setup, but I cleared the bone roll (control-n in edit mode) and I re-oriented the gun and target so that it’s not pointing down in the scene and it’s pointing sideways because it was easier for me to visualize it when up is actually up. Then I re-applied the track to constraint and things work like you want, I think. I attached the fixed blend file. Hope that helps!


HELP_fixed.blend (157 KB)

Thank you, thank you, it works now, except that I needed to turn the gun upside down (don’t know why, everything looked the same as yours), but that’s just a minor inconvenience, as I can always apply the armature to affect it in edit mode, if that’s even necessary.

Whoops, turns out that the bone was (somehow) off center, that was making it turn upside down.