I am new to JmonkeyEngine and I am trying to make a box move towards another point. I have tried looking it up, but I can’t seem to find a solution to what I am sure is a stupid question. I can’t use a CharacterControl, I believe, since it is not on the ground, but I can’t figure out another way. Thanks for helping out a noob like me!
(1) Figure out the velocity (direction and speed) you want the box to move.
(2) On each update (in SimpleApplication.simpleUpdate() perhaps) calculate the offset as velocity times time (tpf) and add the offset to the box’s current position (using Spatial.move() perhaps)
Sorry, but I am a bit confused. Could you help me with an example? Lets say I have a Vector that is (3f, 2f, 1f) and I am trying to move to (2f, 4f, 3f). How would I accomplish this?
Ok, so I figured it out. Here is how you could solve the previously stated example:
Vector3f location = new Vector3f(3f, 2f, 1f) Vector3f targetLocation = new Vector3f(2f, 3f, 3f) float speed = 0.01f; Vector3f trajectory = targetLocation.subtract(location); trajectory = trajectory.normalize(); Vector3f offset = trajectory.mult(speed); spatial.move(offset);
I used this as the source: java - jmonkey rotation and translation - Stack Overflow
Thanks for the help!