chandlerprall / GoblinPhysics

Collision Detection & Response in JavaScript
http://www.goblinphysics.com
Other
147 stars 18 forks source link

FPS character rotation restrict to Y axis #66

Closed Druidhawk closed 8 years ago

Druidhawk commented 8 years ago

I am using goblin as the physics engine of my threejs base game. I am hitting the typical error where moving character falls over themselves when they move. I am using linear velocity to move by the way. I don't want to hack the goblin rotation every iteration and thought some variant of the hinge constraint might work. Any thoughts??

chandlerprall commented 8 years ago

Sorry @Druidhawk , just saw this question.

You can prevent rotation on the X and Y axis by modifying the body's angular_factor:

body.angular_factor.set( 0, 1, 0 );

the default is 1, 1, 1 which allows full rotation on all axis