It gets the correct Node (I see by the name)
Then when calling getWorldTranslation() for that joint’s node you get some value
If you doing it again, you get another value - the correct value
I will try to write a class with only the relevant code to reproduce the problem
This is because I’m not a native English speaker.
What happens is that sometime when the game is running and the character is loaded and active (move, animation etc.) I need to display another object in the position of a given joint (not attach, just position. attaching works fine) then I’m looking for the joint’s node, fetch it’s worldTraslation and uses that for placing the other object. as I said, first time doing so gets wrong position, second time - works fine. It’s possible that I’m abusing the joints in some way I dont know but it’s pretty straight forward…
I’ll try to write an isolated program reproducing it.
I don’t know if it’s a bug or by design but until the control actually runs the bones have old positions and the newly created joint bone won’t have been updated yet. So more a matter of “attachment bones were not designed to be used the way you are using them”.
I ask again:
Like, why does n.attachChild(yourThing) not work in this case.
Sometimes if you explain WHY you are trying to do something then it helps a lot more than trying to explain how to levitate out of a room where you are standing in a corner surrounded by paint.
If I attach the spatial to the joint’s node, it will start moving according to the movement of the joint. I just want to place it there not to make it move with the joint. Am I missing something?
I simply wanted to place an object in the world position of a given joint.
Is there an alternative way or best practice to fetch the joint’s world position other than using it’s getWorldTranslation() method?
And I’m trying to understand why attachChild() is not doing that.
But alas we are at an impasse because this conversation has become circular and my questions back are not really getting answered. I’m apparently not the right person to help so I’m going to bow out and let someone else try.
I think if you want to do what you are trying to do that you will have to call update on the animation control or call that animated spatial’s updateLogicalState() to force it to update before it wants to.
Since I think it sounds like you want translation to be updated but not rotation. (even though I asked specifically that and got no reply)
Probably the “JME way” would be to add a control to the joint node that updates the world translation of your spatial. Then you will know it always runs at the right time and will never be a frame behind. You also won’t have to run extra passes of updateLogicalState() just to make things right.
I will try anything you say and I’m sure I will find a workaround for getting the correct joint’s world position at any given time but the the purpose of this post is to also to check whether or not JME has a defect when using a joint’s getWorldTranslation() for the first time and if it does have a defect I will report it as an issue on the engine’s GitHub repo.
Here is a video I have recorded reproducing the problem:
I loaded a character and have it moving Left 2 meters for 3 seconds 5 times
After each time, I called the “Head” joint’s getWorldTranslation() method trying to receive it’s position and place there a little spaceship
As demonstrated in the video - calling it for the first time yields a wrong position while calling it every other time will give the correct position.
So again, what do you think? is it a bug and I should create a new issue in GitHub or is it by design?
Thanks for your answers