Can someone please explain this to me! Thx~

i used a ray detection to keep my player model on the surface of my ground model.

it works perfectly fine if i do not initialize my player's model's localTranslation, but only set my player Node localTranslation to a random value.



however, if i set the model's localTranslation equals the Node's localTranslation, the player model appears above the surface by exactly the same distance between the two models when it was working fine.



      player.setLocalTranslation(initialPostion);
      player.model.setLocalTranslation(player.getLocalTranslation());  <


  It works fine without this line.



Please help me on this question. I really wanna understand y this is happening.

that's how the scene graph works. local translations are always relative to the parent's local translation.



so you have a player spatial (node or whatever) which has a model child spatial (geometry or whatever you like).

there are 2 types of translations: world and local. the world translation is always in "absolute" world coordinates while the local translation is always relative to the parent's local translation.



let's assume you use only X translation and set the local translation of "player" to 10 and the local translation of "model" to 5. after calling updateGeometricState:

  • player will have it's world translation set to 10 and the local translation of 10 (assuming "player" has no parent)
  • model will have a world translation of 15 and the local translation of 5



    so what your code does is set the local translation of player to 10 (initial location) and then set the local translation of "model" to the same value. that's 10 + 10 in world coordinates (what you see on your screen). that's why you get that offset.



    if i missed the point in your question, then please ignore my post(my blood sugar is very low right now because i had to skip breakfast :x ).
sfera said:

if i missed the point in your question, then please ignore my post(my blood sugar is very low right now because i had to skip breakfast :x ).


thx alot sfera! that was really well explained. now i understand jme more ha :D

sry for the newbie question. still a learning student.

i havent been eating breakfast for the past month, coz i wake up at 2pm  :D

i'm glad i could help