A Behavior Not Expected

Object1.reparentTo(Lhandbone)
Object1.setX(Object1, 0.3)
Object1.setY(Object1, -0.5)

In the above code, I attached an object to a bone of an Actor and off-set it. Object1 is current in the scene graph because it’s attached to the bone of an Actor that is in the scene graph.

Now…

I detach Object1 -

Object1.detachNode();

Object1 is now out of the scene graph. You would think any positioning while attached to Lhandbone would be obsolete because of the detachment, but I found out that’s not true.

Object1.reparentTo(Lhandbone)
Object1.setX(Object1, 0.3)
Object1.setY(Object1, -0.5)

I re-attach Object1 to the bone only to discover that the positioning is not the same. Object1 is in fact out of position!!!

I had a theory which concluded Object1’s positioning was some how stored and Object1 did not need to be re-position because of the re-attachment. I figured I should preset Object1’s position while attached to the bone and then detach Object1 for re-attachment later (without setting positioning again). This method worked but is a little out of the way, don’t you think?

So what is going on here?

It’s like the origin of Object1 is being moved, instead of Object1 just setting its X and Y values based on itself.

So, with that noted, there has to be a difference between these two -

E.g. -A:

Object1.reparentTo(Lhandbone)
Object1.setX(Object1, 0.3)
Object1.setY(Object1, -0.5)

E.g. - B:

Object1.reparentTo(Lhandbone)
Object1.setX(Object1.getX() + 0.3)
Object1.setY(Object1.getY -0.5)

The outputs of those two are different. I clearly needed the output of E.g. -A, but did not want the origin of Object1 to change. If the origin changing is not the case, then why was the position not the same every time I detached and re-attached?

Drwr… what have you done here?

Lol

Just kidding. :slight_smile:

you don’t change the origin, you move the object relative to itself, twice. each time you do, it will move further from its original postion.

either reset the position relative to the bone.
or set the position relative to the bone directly. unless you have your object rotated or scaled, the later option makes more sense.

option1:

object1.reparentTo(lhandbone)
object1.setPos(0,0,0)
object1.setX(object1,0.3)
object1.setY(object1,-.5)

option2:

object1.reparentTo(lhandbone)
object1.setPos(0.3,-.5,0)

I actually tried that and it didn’t work for me; that’s why I posted because I was stunned. I drop the application anyway. I’m going to do something else.