Parented obj has animation lag (bug in bge itself)

Hello,

my parent chain:

weapon -> empty -> right_hand_bone
mesh -> armature ->bounding box

So that is a default setup

Now i play a walk animation on the armature, arms move up and down, weapon moves up and down as well, so far so good. The problem is the weapon lags behind, i mean hand goes up weapon goes up like 1/10 of a second later. this causing unwanted/annoying behavior/looks.

All the transforms are correct also tried to set the animations to linear/brezier/etc, gets a little less but that is due to the smoothing of the animation, i personally think that the empty is ‘lagging’ behind, but i’m not sure.

Anyone know a solution for this? (video few posts lower)

blend with the problem
parent position problem.blend (493.5 KB)

-> Solution, saying goodbye to blender, and hello to upbge 0.2.4.

have you looked into the object tab if there is a slow parent activated?

No, but i’m 100% sure that that is off.

could it be that you pressed o by accident? the key is too close to p and activates proportional editing. maybe you animated the object with that active?

O/snap does not work during runtime. anyway ill make a video, give me a few minutes
and slow parent is indeed off on all objects.

here, look at weapon/hand position:


(dont mind the stutter it’s due to bad drivers)

it looks like it’s parented to the origin of the skeleton and not a bone. look at the parent of the empty or weapon.

parented to armature->bone->hand.R, so that’s not it

Hmm another fun fact: it only does that if i look forwards, if i look up or down lets say 5/10 degree or more it acts normal.

ok, so it’s not a simple mistake.
could be code or a bug. have you tried unparenting it and parenting it again to see if it fixes the problem? could it be that the origin of the weapon is at a different position than the empty?
edit: also, do you remember when the problem started? what was the last thing you changed before it happened? has it always been like that or is it something recent?

it happend when i added the weapon, because then i noticed and used it.

i extended the add part to this:

    spawner = own.scene.objects['right_hand_empty']
    
    add = own.scene.addObject(weapon, None, 0)
    add.worldPosition = spawner.worldPosition.copy()
    add.worldOrientation = spawner.worldOrientation.copy()
    add.setParent(spawner)
    add.localPosition = [0,0,0]

to make sure everything is correct.

Strange thing is, it does it only when looking forwards.

The only other thing is the empty, and that is parented to the bone.

ok, so the weapon is dynamically added?

mmmh, try:

ob1 = own.scene.addObject(weapon, spawner, 0)
ob1.setParent(spawner)
ob1.worldOrientation = spawner.worldOrientation

you could make the weapon be an object that’s always on the hand and just use replaceMesh() or visible, that would 100% solve the problem.

No this cant, i wrote 1000 lines haha to make some of the ‘player functions’ including the weapon system.

It’s simple object gets added parented, positions set etc. nothing more happens.(look post higher)

so this is a strange thing.

it seems to be a problem with parenting.
another solution is to give the object it’s position and rotation manually.
you have your add script, and then a script that moves the weapon every frame like this:

    spawner = own.scene.objects['right_hand_empty']
    add = own.scene.addObject(weapon, None, 0)
empty = own.scene.objects["right_hand_empty"]
weapon.worldPosition = empty.worldPosition
weapon.worldOrientation = empty.worldOrientation

this every frame, could be in the weapon object, or a script that finds all the weapon objects and applies the changes in a for loop.
it’s essentially the same as parenting, except you are the one doing the calculations.

Tried it, makes things even more noticeable.

It seems it has to do with the animation or armature, anything i parent to a bone has that ‘offset’ even a simple cube.

if anyone knows a solution for this, please tell me.

To som it up:

  • all transforms of all objects are correct.
  • all positions are correct
  • any object that get’s parented to a bone got this ‘delay’
  • python or manual parenting reacts the same (with python it’s actually a bit worse)
  • no slow parent used
  • cannot recreate this behavior in a new/clean blend(turns out i can recreate it, blend below)

then there’s a problem with the armature or the empty. we know it’s not a bug because it works in other armatures, so it MUST be something that you changed by accident.
try creating a new armature and empty and compare the settings on both to see if you find something that’s different in armature, bone or object tabs.
it could also be a problem with a bone modifier if you have one for the arm.
could also be something in the scene/world tab. they added a bunch of new features and changes to armature in new upbge versions.

i was wrong, here a fresh created blend. hit p and you should not see any red on the cube. If you do then you see my problem.

parent position problem.blend (493.5 KB)

OK this is a bug in BGE 2.79 itself. Just downloaded UPbge 0.2.4 and there the test file works correctly, going to see if i can swap my project to UPbge.

ok, i can confirm. bug is present in 2.77 but not in upbge 0.2.2. but must be recent since i remember using parent to bone and it working correctly.
glad you could fix your problem.

moving to upbge should be easy, the only difference is in python keys and a few changes to KX_world.

I know, inputs, asynchronous, etc has changed, rewrote those scripts, animation are broken now so need to redo that as well. But they did fix my libload issue, so i think i gonna need a few days rewriting stuff and then upbge is a go.