Jump to content

[SOLVED] Camera - input mapping and behaviour


CarlBateman
 Share

Recommended Posts

I'm writing an FPS (Asteroids in 3D) and need to change the input mapping and some of the behaviour of the camera (currently Universal Camera).

1. rotate left and right (about the y-axis) instead of move - it does this for the mouse, but not keys
2. when rotating tilt into the direction of roatation - to emphasise the motion and give a "swooping" feel
3. control key sensitivity 

Are these behaviours / properties directly configurable? Or do I need to subclass a new camera type, or develop a different input control mechanism?

Link to comment
Share on other sites

Hello Carl,

By default the current input for keyboard controls only position (https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/Inputs/babylon.freecamera.input.keyboard.ts). To achieve what you want I suggest creating your own input controller.

Doc: http://doc.babylonjs.com/tutorials/customizing_camera_inputs#implementing-your-own-input

Here is a sample for you (it rotate the camera using left/right): http://www.babylonjs-playground.com/#1WFOOA#2

Link to comment
Share on other sites

Brilliant, thanks, that works.

I'm afraid I must admit that, try as I might, I can't understand the documentation, not least since it seems aimed at input rather than control and some of the code is TypeScript(?). I've tried reading it several times to no avail.

The interface does indeed appear simple, sadly actual implementation isn't and seems rather involved for attachControl, detachControl and checkInputs. I'd recommend including the sample you provided in the doco. (I might go as far as to say it's vital.)

Again, thanks. I'm always impressed by the speed and utility of your responses/support. 

Link to comment
Share on other sites

  • CarlBateman changed the title to [SOLVED] Camera - input mapping and behaviour

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...