3

I set up 2 bodies manually & assigned Copy Location constraint to one with respect to another body. Then I set up the keyframe for the guiding body & then I started to view the change in the location of the constrained body. What I noticed in the 3D viewport was the constrained object moves, but when I look into its real position the values are stagnant. Why is that? I was unable to find my answer in previously asked questions by other people !!

Amir
  • 3,074
  • 2
  • 29
  • 55
  • 1
    It's a bit unclear what you mean by "stagnant". Did you try to change the offset and space parameters of the Copy Location constraint? What effect are you trying to create? – TLousky Sep 13 '15 at 09:02
  • I added python & scripting because I want to access the values using the notation --> ob.location[1] – Abhinav Chaudhary Sep 13 '15 at 11:09
  • OK, maybe add some detail about that in your question, since the description doesn't mention it? And maybe try to add more info and images or a screen recording to demonstrate the problem. I at least couldn't understand precisely what the issue is from the description... – TLousky Sep 13 '15 at 12:18
  • related: http://blender.stackexchange.com/questions/28031/getting-the-location-of-rigid-body-object-at-current-keyframe (basically the same question and same answer, but more python-oriented) – rfabbri Sep 13 '15 at 18:54

1 Answers1

5

object.location will never give the "correct" position for a object that has a constraint on it (or a parented object).
That comes from the way parenting and constraints mess with the global coordinates (their effect gets calculated after the object.location).

To get the world position of the a child object (or an object governed by a constraint) you should use object.matrix_world.translation.
matrix_world returns a matrix for the object's transformations in world space. The .translation part will convert the matrix to a location vector (just like .location).


The blender wiki has a good read for further explanation about the coordinates for parented objects (same principals for constraints).

David
  • 49,291
  • 38
  • 159
  • 317