@normen said:
I’ll put down the code here for you but really, you won’t have any fun doing games at all if you don’t understand this code 100%, copy&paste will not make you a happy camper. Better have a look at this: http://jmonkeyengine.org/wiki/doku.php/jme3:math_for_dummies
//*clone* cam direction, else we modify it
Vector3f walkDirection = cam.getDirection.clone();
//remove y component (up/down)
walkDirection.setY(0);
//normalize vector (make length=1)
walkDirection.normalizeLocal();
//multiply length with speed of unit
walkDirection.multLocal(speed);
Not suprisingly it works! Thank you, and thank you for the link too, I will study vectors some more. Well, you are right. I didn’t have fun copy pasting, but I did make my own collision detection and everything else. But, when I find out more about vectors i’m probably gonna make my own code for making the box more where it’s facing.
By the way, why do you want to use cam.getDirection.clone();, can’t you just use cam.getDirection? Or, is it just for good practise?