Skip to content

Instantly share code, notes, and snippets.

@BobTheBuilderBot
Created September 21, 2012 18:56
Show Gist options
  • Select an option

  • Save BobTheBuilderBot/3763220 to your computer and use it in GitHub Desktop.

Select an option

Save BobTheBuilderBot/3763220 to your computer and use it in GitHub Desktop.
public void onAnalog(String name, float value, float tpf) {
walkDirection.set(0, 0, 0);
Camera cam = client.getCamera();
Vector3f camDirection = cam.getDirection().clone().multLocal((playerCharacter.getVelocity()*10)/tpf);
Vector3f camLeft = cam.getLeft().clone().multLocal((playerCharacter.getVelocity()*10)/tpf);
switch(name) {
case "Left":
walkDirection.addLocal(camLeft.mult(value));
break;
case "Right":
walkDirection.addLocal(camLeft.negate().mult(value));
break;
}
switch(name) {
case "Up":
walkDirection.addLocal(camDirection.mult(value));
break;
case "Down":
walkDirection.addLocal(camDirection.negate().mult(value));
break;
}
characterControl.setWalkDirection(walkDirection);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment