Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by paulh

Hi All

Whats the best way of making an entity roate in the direction it is facing, even after bouncing?


If your using ramps how do you affect the entitties acceleration, velocity etc to stimuate that from top down?

1 decade ago by quidmonkey

Untested, but you could maybe fudge collision rotation like this:

handleMovementTrace: function( res ){
	   if( res.collision.x || res.collision.y ){
		  var dx = this.pos.x + this.vel.x * ig.system.tick,
			 dy = this.pos.y + this.vel.y * ig.system.tick;
		  
		  //find the angle between the desired new pos
		  //and the actual new pos after trace
		  this.currentAnim.angle += Math.atan2( dy - res.pos.y, dx - res.pos.x );
	   }
	   this.parent( res );
    }
Page 1 of 1
« first « previous next › last »