Hey there,
I have kind of a weird problem. I have no idea, how to first person control a box...
I have a class structured like this:
I need to find out, how to strafe left - if I try with that solution, it acts weird, going to front, back, side and any way that looks nicer then left. Same with right. I tried every math trick I know, scalar product, simple addition, ...
Forward and backwards work well, just the left and right thing don't.
Would be quite cool, if someone could help me. I am getting depressed by that...
Hope I don't left any information...
I have kind of a weird problem. I have no idea, how to first person control a box...
I have a class structured like this:
Code Select
class FirstPersonControler {
SimpleVector moving = new SimpleVector(0f, 0f, 0f);
SimpleVector facingangle = new SimpleVector(0f,0f,0f);
public void update() {
double nowtick = GameTicks.getSystemTick();
/* Unimportant logic having todo with fps view */
facingangle = c.getDirection();
}
public void strafeLeft() {
moving.add(new SimpleVector(-2f, 0f, 1-Math.abs(facingangle.z)));
}
public void strafeRight() {
moving.add(new SimpleVector(2f, 0f, (facingangle.x*2f)/facingangle.z));
}
public void forward() {
moving.add(new SimpleVector(facingangle.x, 0, facingangle.z));
}
public void backward() {
moving.add(new SimpleVector(-facingangle.x, 0, -facingangle.z));
}
public SimpleVector getMoveVector() {
return moving;
}
}
It controls the way, the box is moving, woth looking how the camera is turned. Then you should be able to control the box with "WASD" and turn around with the mouse, but that doesn't work well I need to find out, how to strafe left - if I try with that solution, it acts weird, going to front, back, side and any way that looks nicer then left. Same with right. I tried every math trick I know, scalar product, simple addition, ...
Forward and backwards work well, just the left and right thing don't.
Would be quite cool, if someone could help me. I am getting depressed by that...
Hope I don't left any information...