/PlayerControls

Three.js 3rd person player controls

Primary LanguageJavaScript

PlayerControls

PlayerControls is a modificatin to the three.js script, OrbitControls.js: https://gist.github.com/mrflix/8351020

PlayerControls enables quick and easy access to a 3rd person player controller:

  1. "import" three.js library
<script src="js/three.js"></script>
  1. "import" PlayerControls.js
<script src="js/PlayerControls.js"></script>
  1. instantiate PlayerControls object ( pass camera and player object as arguments )
var controls = new THREE.PlayerControls( camera , player );

Keep in mind that player is a mesh or group object with position.x, position.y, etc.. properties

  1. update controls in animate function
function animate() {

	requestAnimationFrame( animate );

	// other things you do..

	controls.update();
	
	render();

}

You can adjust the speed of the player with:

controls.moveSpeed = some_number;

You can adjust the turn speed with:

controls.turnSpeed = some_number;