I was just messing around a bit and made a simple gun turret that tracks to an empty, but I’m having trouble limiting the rotation of the gun barrel so that it won’t pass through its own base when the empty is beneath it. I’ve been messing around with the limit rotation constraint for a while now, but all my results seem nonsensical. It’s hard to describe what happens, so here’s the .blend. turret.blend I’d also like to set an upper limit for the rotation so the gun doesn’t flip upside-down when the empty passes overhead.
[Edit] I have it semi-fixed. If you pass too close to directly overhead or underneath it still breaks. turretsemifixed.blend Pass the empty overhead and down the other side in side view to see what I mean. It also does this when you are close to overhead and the turret has to rotate quickly.
Click on limit x min -90, max 90 ( you could use higher )
I don’t think you can keep the barrel from flipping, but I’m not sure that is what is happening. Move the empty slightly off center in top view ( slide along x axis ), then move it over the turret. At a certain point, you will see the barrel and mount rotate rather quickly. I think the problem lies in that when the Empty is dead on in the X axis, this rotation happen extremely fast. Like trying to rotate an object in Blender when your mouse is directly over the center.
That’s what I thought, but it happens even if the empty is not exactly dead on the axis. In top view, grab the empty to the right .5-1 BU or so. Go into side view, and grab the empty to well below the gun, so it can’t go any further. Now move the empty to the left of the Z axis. At a certain point the gun will go screwy.
[Edit] Just in case you can’t reproduce it, here’s a screen capture. .avi 409 kb DivX 6.6
OK, Basically, what I did with turret, was to rotate the barrel object so it was horizontal, then applied rotation and location etc. Then instead of a locked track, I used a Track To constraint, and a Limit Rotation constraint with X min -20 and Max 90 and it seems to work.
Turret2 - OK, I’m just getting into armatures so there was some swearing involved blah blah I made it work.
Thanks! What I didn’t do was rotate the barrel to the zero point and apply rotation. Makes sense now that I know what it is. Thanks again, it works flawlessly now!