Skip to content

Instantly share code, notes, and snippets.

@keyle
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save keyle/ece0f90a4a72e9b0a9fb to your computer and use it in GitHub Desktop.

Select an option

Save keyle/ece0f90a4a72e9b0a9fb to your computer and use it in GitHub Desktop.
Fullscreen FPS the right way?
stage.addEventListener(MouseEvent.MOUSE_MOVE, mousemove, false, 0, true);
scene3D.addEventListener(Scene3D.UPDATE_EVENT, update, false, 0, true);
private function mousemove(event:MouseEvent):void
{
if (event.movementX != 0) {
const mouseMoveX:Number = (event.movementX);
spinX += mouseMoveX * 0.035;
}
if (event.movementY != 0) {
const mouseMoveY:Number = (event.movementY);
spinY += mouseMoveY * 0.035;
}
}
private function update(event:Event):void
{
player.rotateY(spinX, true);
spinX *= .51;
scene.camera.rotateX(spinY, true);
spinY *= .51;
}
@keyle

keyle commented Aug 30, 2014

Copy link
Copy Markdown
Author

When I move the mouse left slowly while moving forward (WASD), the camera goes spastic. That's why I tried to fix it with spinX *= .51;

Still not great.

Any help appreciated :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment