Movement: Direction and Velocity

So I literally bulged my eyes out on this issue and I still haven’t figured it out yet.

I want to move an object in 3D space, where the user can decide the direction of movement, and how fast it moves.I am aware that the direction of movement is adding the location vector to the direction vector. Whenever I tried doing that, the objects either didn’t move at all or they immediately rushed from the screen after I pressed a key :smiley:

At the moment I have something looking like this but it doesn’t seem to work at all (Mostly due the fact I’m not very mathematically talented)


Vector3f loc =Object.getNode().getLocalTranslation().clone();

Quaternion dir = Object.getNode().getLocalRotation().clone();

loc = dir.mult(loc);




I need to somehow get the current “user input rotation”, then add it up to the current location of that object to get the new location. To adjust the rotation of the object, I’m using .lookAt() - however that does not function as I intended either when I’ve tried it. I’m not sure how to implement velocity in this though. Now my question is, how does all of this look in code?

I do have troubles understanding how this works, so any help is greatly appreciated.

to move in the direction you are facing you want to do:

[java]Vector3f loc =Object.getNode().getLocalTranslation().clone();

// assuming that the model mesh faces towards the screen

Vector3f dir = Object.getNode().getLocalRotation().mult(Vector3f.UNIT_Z).normalizeLocal();

Vector3f newLoc = loc.addLocal(dir.mult(0.5f)); //where 0.5f is some scalar value to move in the direction you are facing[/java]

Thanks a lot for the fast reply

I think I know where you getting with this - but perhaps I worded my problem wrong, though. I want to move the objects like it is the case in a flight simulation. I still think I that code you showed me can be handy so thanks again :>

after doing some research I think I may be using the wrong tools to do what I intended. I think the com.jme3.bullet.* packages could help me out here. Just a note to those who wanted to something similar.