So let's imagine I have a gun pointing at a target. Gun has copy location constraint to locate to another object that rotates around the same axis as the gun. Gun has track to constraint to keep it pointing towards the target (just up/down movement, rotation around its y axis which is x axis in world space). On it's 0-position there is an initial angle of about 10 degrees of up (measured by hand).

How do you actually get the gun rotation so I can set its allowed range to -55 to +55 deg? How do I even get the gun rotation value at all? The gun object rotation in the n.menu transform panel is 0 and never changes no matter how I move the target. I've tried using limit rotation constraint but it is totally broken and just set's the object rotation to its max value

Here is a sample file: http://www.mediafire.com/file/c4x62lx6kmil7nu/constraints.zip/file The rotation of the rectangle object causes the "gun" to go outside of its rotation limits. The cylinder should point towards the target as long as its angle is inside its local rotation limits. These rotation limits come from the rectangle object.

In other words the angle limit is for the angle between the rectangle and the cylinder. Cylinder moves with the rectangle (rectangle just rotates) and cylinder points at the target as long as its angles are inside its limits.


The file you've linked works as it is supposed to work, you've given a Limit Rotation on the X axis of -30° and 30°, as seen below. 0° on the X axis is a flat axis (in Global axis but also in cylinder's Local axis if you ever switch to it).

enter image description here

If you want the gun to follow the angle you're displaying you need to choose Min -60° and Max 0°.

enter image description here

If you want the angle to be relative to the rectangle rotations, don't use a Copy Location for your cylinder, parent it to the rectangle so that it's new Global orientations depends on the rectangle, not on the world. Also don't forget to limit on Z so that it doesn't flip.

  • $\begingroup$ Rotate the rectangular piece and the limits are exceeded. The cylinder follows the rectangle and doesn't respect its rotation limits $\endgroup$ Jul 1 '20 at 11:20
  • $\begingroup$ because you've given your cylinder a Copy Location constraint, Copy Location won't change the cylinder's Global axis, it is still the world, but if you parent it to the rectangle, it will consider it as its new Global axis $\endgroup$
    – moonboots
    Jul 1 '20 at 11:29
  • $\begingroup$ ok, that works, thank you. Is there a way to get the rotation angle for a constrained object? The cylinder angle still stays 0 no matter what. The limits work but how do you get the angle it is at? $\endgroup$ Jul 1 '20 at 12:27
  • $\begingroup$ I don't know, maybe you should open a new question $\endgroup$
    – moonboots
    Jul 1 '20 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.