Thanks fpr your reply.
I've been a bad explainer like my whole life ^^
I want to move an object in the world depending on the rotation if the camera.
I have this code right now: public class FirstPersonControler {
private Camera c;
SimpleVector moving = new SimpleVector(0f, 0f, 0f);
private SimpleVector xangle = new SimpleVector(0f, 0f, 0f);
private SimpleVector zangle = new SimpleVector(0f,0f,0f);
public FirstPersonControler(Camera c) {
this.c = c;
lasttick = GameTicks.getSystemTick();
}
public void update() {
double nowtick = GameTicks.getSystemTick();
moving = new SimpleVector(0f, 0f, 0f);
/* Code for turning the camera with the mouse */
xangle = c.getXAxis();
zangle = c.getZAxis();
tickcount = nowtick - lasttick;
lasttick = nowtick;
}
public void strafeLeft() {
moving.add(new SimpleVector(xangle.x * (-1), 0, xangle.z * (-1)));
}
public void strafeRight() {
moving.add(new SimpleVector(xangle.x, 0, xangle.z));
}
public void forward() {
moving.add(new SimpleVector(zangle.x * (-1), 0, zangle.z * (-1)));
}
public void backward() {
moving.add(new SimpleVector(zangle.x, 0, zangle.z));
}
public void jump() {
gravity = 1.2f;
}
public void forceMove(SimpleVector sv) {
this.forcedmoves.add(sv);
}
public SimpleVector getMoveVector() {
SimpleVector ret = new SimpleVector(moving.x, moving.y, moving.z);
if(ret.length() > 0) ret.scalarMul((1f/ret.length())*(float)(tickcount/2f));
return ret;
}
}
Every tick (~5ms) I check for the pressed key
w = FirstPersonControler.forward()
a = FirstPersonControler.strafeLeft()
s = FirstPersonControler.backward()
d = FirstPersonControler.strafeRight()
Then I move an object with the Vector FirstPersonControler.getMoveVector() and put the camera right on top of it.
Using the code above make the camera move weird; when pressing "a", it doesn't move to how it should.
I want to calculate the vector I need to translate, if I want to move the camera to the left (with calculating its rotation)