I’m trying to create a “2d” fighting game in a 3d world (where the camera angle can change and the “rotation” of left/right can change)… eg +x isn’t always going to be right or anything like that
Both players are already confgured to be “facing” eachother (with charactercontrol.setViewDirection())… Now I need to make it so they can walk towards and away from eachother. I feel like this should be most easily done by using the view direction vector to determine “forward and backward”… however in order to do this I also need to know which way is left/right (which is based on the camera location)…
I just can’t figure out how to take the camera’s position (and possibly also the rotation?) and use it to determine if that when the player pushes RIGHT that the character should move in view_direction or view_direction.clone()
Here is the code I have so far…
[java]
private Vector3f getDirectionToSecondSpatial() {
Vector3f direction = secondSpatial_physics_control.getPhysicsLocation().subtract(physics_control.getPhysicsLocation());
direction.y = 0;
direction.normalizeLocal();
return direction;
}
public void controlUpdate(float tpf) {
Vector3f view_direction = getDirectionToSecondSpatial();
physics_control.setViewDirection(view_direction);
Vector3f cam_loc = camera.getLocation();
Vector3f my_location = physics_control.getPhysicsLocation(); //somehow use this to determine which way is right?
WalkDirection walk_direction = input_control.getWalkDirectionFlag();
switch (walk_direction) {
case Left:
walk_direction_mult_speed = view_direction.negate(); // THis is the kind of concept I'm trying ot achieve. but this isn't exactly what I want.
break;
case Right:
walk_direction_mult_speed = view_direction.clone();
break;
case Idle:
default:
walk_direction_mult_speed = Vector3f.ZERO.clone();
break;
}
walk_direction_mult_speed.multLocal(this.walkForewardSpeed);
physics_control.setWalkDirection(walk_direction_mult_speed);
}
[/java]
THats the gyst of what I’m trying to do. just using the view_direction vector isn’t what I want. I want the player to walk along that vector but use the camera’s location to determine which direction…