[Help] Rigid Body Joint On Moving Objects Displacement/Async

Hello Blenderartists,

so I’m learning UPBGE 0.2.4 and I’ve created a scene where my character is holding a lanter in his right hand (Video Example 1). I’d like to use physics to simulate its swinging while my character walkes around. But using a Rigid Body Joint Constraint does not really constraint my object while its target moves around (Video Example 2). Before it lags behinde and in this example it over shoots (WTF)

I’ve wasted 2 Days manipulating the objects position with a python script, I’ve tried to variate both physics and logic steps to some how synchronize is (I’m losing my mind).

My question: How can I get the simuated object actually be fixed at his moving target? Do I have to create the constraint in python to synchronize it? Or do I’ve to study physics and recreate the simulation by my own?

physics motion is different from simple motion, and simple motion is one frame offset from the physics calculated position.

try moving the object with apply force or linear velocity

Thank you for having your time.

Good to know. This explains the offset.

Linear velocity could work. Right now I am parenting an empty object(constraint target) near the characters hand to my character.

Then applying linear velocity on my character does work and I barely get any displacement. But what if I want to crouch or throw the object? Best way would be if I can somehow use the hand bone position and set my target position to it. But then I am facing the same problem of displacement.

Is there a way to parent/place my target object at my hand bone? Then a could animate my character in sort of way and don’t have to worry about breaking the physics again.

you can parent an empty right on a bone, then parent things to that empty dynamically. you cant parent to bones in runtime.

the slowness is caused by damping, you want the damping to be set to zero and set linear velocity to zero at the top of you movement script

1 Like

I’m taking a break or else I’m going to give up again. I may post an update in a few days. Thank you for helping me out.

if you want it to align to physics / constraints - use pre_draw callback to move it*

def function():
   #do stuff

def main():
    if 'init' not in own:

also to set a relationship like parenting by hand we can do

if 'StoreData' not in own:
    parent = own.scene.objects['SomeObject']
    pos = parent.worldOrientation.inverted() * childObject.worldPosition
    rot   = parent.worldOrientation.inverted() * child.worldOrientation
    own['StoreData'] = ( pos, rot, parent)

to store data on frame zero about where something should be in space*

later to use it to set * (from memory)
#I may need to look this up but it should be close

pos = parent.worldTransform * own['StoredData'][0]
rot =  parent.worldOrientation  * own['StoredData'][1]
1 Like