Skip to content

PiusNyakoojo/PlayerControls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

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;

About

Three.js 3rd person player controls

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published