0
$\begingroup$

I have two cylinders, one is the puck, other is the handle. The handle is child of the puck. They both have dynamic physics. I use python to define their motion. As soon as I hit p and enter gaming/testing mode, their locations are changed. But the handle has more dramatical location change than the puck.

enter image description here

Here is two photos of before and after hitting p:

Before:

enter image description here

After:

enter image description here

I cannot figure out why this sudden change of location and getting compressed in y direction.

Here is my script:

import bge


def main():
    cont = bge.logic.getCurrentController()
    scene = bge.logic.getCurrentScene()
    keyboard = bge.logic.keyboard
    puck = cont.owner


    # sensors
    bottom_edge_collision = cont.sensors["bottom_edge"]

    # keys
    r_pressed = bge.logic.KX_INPUT_JUST_ACTIVATED == keyboard.events[bge.events.RKEY]

    if r_pressed:
        scene.restart()
        print("rsrt", puck.localPosition)


main()

Here is my blend file: https://drive.google.com/drive/folders/1dcXSZ7HHZH9h8f6KFJWUsVmuRl69o6bd?usp=sharing

$\endgroup$
  • $\begingroup$ You do not need "main()" and "def main()". It makes the code harder to read. $\endgroup$ – Monster Jan 16 '18 at 5:09
0
$\begingroup$

Without seeing your blend file we can only guess. The most likely candidate is a non-unit scale. Select the objects, press CTRL+A and choose "Scale". This applies the object-level scale factor to the mesh itself, and resets the object-level scale to (1, 1, 1).

$\endgroup$
0
$\begingroup$

This sounds like an old bug of Blender (which can't be compensated by the BGE).

in Blender:

  • Unparent the objects.
  • Reset both objects to the scene origin (Rot, Pos, Scale).
  • Parent them together
  • move the parent to the desired location.
$\endgroup$
  • $\begingroup$ When I use no scale, your solution is perfect. But when I make the handle slimmer, same problem occurs. How can I make a thin-long handle other than using scale? $\endgroup$ – Saba Jan 16 '18 at 14:01
  • $\begingroup$ As mentioned in the other answer, apply the scale, which deforms the vertices rather than the object. $\endgroup$ – Monster Jan 17 '18 at 13:47

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.