After further research it seems this is actually a bug, the only way to fix it is probably through an update to the engine, I’ll submit a bug report to the BGE bug tracker.
See blend file: enginegameparentchildrelationships.blend (444 KB)
Quickly made an example blend file to see what I mean, when you press P the sphere changes rotation. What I expect is, being that the sphere is parented to the empty, the sphere to act as though it resides in the empty’s “Universe”, this works correctly in the editor, when you rotate the sphere it rotates within the empty, however once you press P and launch the game engine, the sphere no longer seems strictly bound to the empty’s borders.
Weird. It should probably display what the BGE displays - the ‘rotate within the parent and copy its scaling locally’ behavior doesn’t seem correct…
If you render the image the renderer uses the same configuration as the editor. The technique is really useful, for example, for doing squash and stretch with a ball and having the ball rotate with that squash still applied, all without having to counter-animate. The game engine’s interpretation then becomes the part that seems weird in that context, by not implementing the relationship in the same way as the editor.
Edit: Anybody got any clues for a workaround?
After some tinkering I learned some more about lattices. You can create the same effect with a caveat, the sphere becomes unrenderable in the game engine, making the small amount of excitement I experienced thinking I figured it out moot. No way to get objects affected by a lattice in-game? Hmm wonder if I can find some other solution.
Edit: After further research it seems this is actually a bug, the only way to fix it is probably through an update to the engine, I’ll submit a bug report to the BGE bug tracker.
is the empty that not have a scale as other obj , if you replace the empty with a cube(mesh) it work as expected.
anyway i see it as a bug.
all thing broken not should be visible when there the render [game engine]
I’m sorry I’m having some trouble understanding some of what you said, you say you found a work around?
yes, use a normal mesh [SHIFT+A-> mesh-> cube] instead to the obj empty.
and parent the sphere to the cube-mesh
I did as you said but it still moves when you press ‘P’: enginegameparentchildrelationships2.blend (474 KB)
true, it not solve the problem .
i think to have found the bug,
it is in localTransform(4x4) that , make a transformation of position and orientation , but not the scale with the parent obj.
in the blend below , that make the sphere with the code should be done automatically with parent + applyRotation .afaik
(to note that worldTransform is almost new , (from 2.62) and the scale is not used pretty much in game)
bugScale.blend (151 KB)
Remarkable! I was trying to compile blender all day after someone told me that if I didn’t do it myself I could be waiting more than a year before someone came and fixed this bug. A whole day spent and I wasn’t able to compile the newest SVN version, let alone have time to look through a code base I don’t understand
(I had a hunch I’d find what I was looking for in the “Convert Blender Data” step as seen on this graph: http://wiki.blender.org/uploads/6/6f/Game_Engine_VisualOverview.png I don’t even know if that’s where the problem lies or not). The guys on #blendercoders were really helpful however, the only reason I couldn’t compile it is because I ran out of time.
The good news seems to be that if they don’t fix it in the code base people can use your script to bypass the problem!
I updated the bug report with a link here and uploaded your .blend file: http://projects.blender.org/tracker/index.php?func=detail&aid=33512&group_id=9&atid=306
Thank you Marco!
thanks , really i make a bit of mistake
also if the results can be similar , localTransform , not should be touched !
script for the sphere, children of the cube deformed:
import bge, mathutils
cont = bge.logic.getCurrentController()
sphere = cont.owner
#this line below should make the same thing (…i guess)
sphere.worldTransform *= mathutils.Matrix.Rotation(0.01,4,“Z”) #this work
#sphere.applyRotation((0,0,0.01),1) #this not keep in count the scale of the parent obj
also as workaround is more short …