Skip to content

Commit

Permalink
Fix rotatable objects rotation when y velocity is zero, see #137
Browse files Browse the repository at this point in the history
  • Loading branch information
andrealin committed Aug 11, 2017
1 parent 657fe95 commit 9d8d243
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/common/view/ProjectileNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,12 @@ define( function( require ) {

// only rotate the object if it doesn't have an assigned benchmark, or it is an object that rotates
if ( objectType ? objectType.rotates : true ) {
var angle = Math.atan( dataPoint.velocity.y / dataPoint.velocity.x ) ||
( dataPoint.velocity.y > 0 ? Math.PI / 2 : 3 * Math.PI / 2 );
if ( dataPoint.velocity.x ) { // if x velocity is not zero
var angle = Math.atan( dataPoint.velocity.y / dataPoint.velocity.x );
}
else { // x velocity is zero
angle = dataPoint.velocity.y > 0 ? Math.PI / 2 : 3 * Math.PI / 2;
}
projectileObjectView.setRotation( -angle );
}

Expand Down

0 comments on commit 9d8d243

Please sign in to comment.