getAngleToPoint( x, y)

Returns the current angle you would need to give .direction for this entity face towards the given coordinates

  • x : number //
  • y : number //

Examples

const box = $.makeBoxCollider($.w/2,$.h/2,50,50);
function update() {
    $.text.alignment.x="left";
    const angleToFace = box.getAngleToPoint($.mouse.x,$.mouse.y);
    $.text.print(20,20,angleToFace.toString());
    box.rotation = angleToFace;
    box.draw();
}