Stupid question

Hi all monkeys, this is a very stupid question but i’m really in trouble because i’m trying to do a network control that sends a message only when a spatial have done enough movement but it seems to be wrong…

[java] @Override

public void update(float tpf) {

// Controllo la distanza tra le due posizioni dall’ultimo update

float distance = oldPosition.distance(spatial.getWorldTranslation());

// Se mi sono mosso allora invio il pacchetto al server

if( distance > 1 ){

MovementMessage message = new MovementMessage(spatial.getLocalTranslation(), true);

System.out.println("Sending message: "+ message.getNewPosition() +

" from source: "+ client.getId());


oldPosition = spatial.getLocalTranslation();



So the question is: how can i retrieve the position of a spatial?

THX A LOT!! :slight_smile:

Make sure you’re cloning the Vector3f when assigning it to oldPosition… or just store the raw x,y,z values

Ok, it goes!! Thx a lot.

But i can’t Understand the difference beetween LocalTranslation and WorldTranslation. Another things i don’t understand is how to move in the correct way a spatial.

For example what are the differences using:





What are the differences?

Pls don’t tell me to watch the SceneGraph for dummies XD


AHAHAHHAHAH ok, i got it :wink:

There’s a great analogy I found the other day about translations, I don’t remember where, but it explains clearly those differences.

Imagine and think about this.

Consider your house, apartment, the “world”. The “origin” is the doorway.

Now, when you say, setWorldTranslation(2, 2, 2), you are moved 2 feet in front, 2 feet right and 2 feet up from the doorway.

When you say, setLocalTranslation(2, 2, 2), you move 2 feet in front, 2 feet right and 2 feet up from where you FIRST APPEARED in the house, independently of where you’re standing in the house. (Or if you prefer your own origin in the house).

When you say, move(2, 2, 2) you move 2 feet in front, 2 feet right and 2 feet up from your CURRENT position in the house, independent of your own location/translation ORIGIN and the house location/translation ORIGIN.

Hopefully that’ll help you and maybe others to visualize this.

Now i’t all more clear! You’re illuminating!! :wink:

Thanks a lot madjack