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

1 decade ago by TrexKikBut

I need help with another problem:

I want my entity to point directly at the cursor, but I don't know how to offset the angle.

How can this be done?

this.currentAnim.angle = Math.atan2(ig.gui.cursor.pos.y - this.pos.y, ig.gui.cursor.pos.x - this.pos.x);

1 decade ago by Datamosh

You can use a picture or an entity and position in mouse X/Y:

Some time ago I made this plugin can be useful:

You can set the cursor anytime with:

or remove:

In your entity (player) update:
if(ig.input.pressed('mouse1')) {, this.pos.x, this.pos.y, {
		source: this,
		click: {
			x: ig.gui.cursor.pos.x +,
			y: ig.gui.cursor.pos.y

In your weapon init:
this.angle = Math.atan2( - this.pos.y, - this.pos.x);
this.vel.y = Math.sin(this.angle) * 100;
this.vel.x =  Math.cos(this.angle) * 100;

1 decade ago by TrexKikBut

I'm getting this error:

Uncaught TypeError: Cannot read property 'cursor' of undefined - Player.js:37

Line 37:
	x: ig.gui.cursor.pos.x +,

1 decade ago by TrexKikBut

Neither of your things are working for me, I can't draw the cursor either.

1 decade ago by TrexKikBut

Its WOrking

1 decade ago by Datamosh

Everything works fine?

Later I will add offset (x / y) to the mouse cursor. In some cases it may be useful to specify where is the 'hotspot' in the image.

1 decade ago by TrexKikBut

I have a new question. Read OP
Page 1 of 1
« first « previous next › last »