# How perform for obj follow mouse with angle?

how i can perform for sprite follow mouse if i change angle ? If i change angle the sprite no more follow mouse correctly. I absolutely need the obj follow mouse with pivot.

https://jsfiddle.net/jonforum/ow9w7rfz/10/

thank a lot for help

edit: if you can help me with math problem !

How i can compute from a sprite (radian.skew,pivot) a new point XY ?

Example i move pivot to XY. And i move rotation to ( randian || degree ) After i move again pivot with mouse compute... all became weird..

How i can compute rotation but base on the position from pivot ? for now here it my try code. thank guys, i have difficult with deep math. Also, I would like to compute skew

## 1 Answer

This looks like it might be as simple as setting your position, instead of your pivot.

// add a graphics instance
var rec = new PIXI.Graphics();
rec.beginFill(0x00ff00);
rec.drawRoundedRect(-20, -65/2, 40, 65, 4); // Shifted so the rect is centered across 0,0

// setup
rec.pivot.set(0,0);                         // Pivot at the center 0,0
rec.position.set(500/2,500/2);
rec.rotation = 45 * Math.PI / 180;
stage.addChild(rec);
renderer.render(stage);

//** listener ********
var updatePosition = function(event) {
this.position.set(event.layerX,event.layerY); // Set postion, no offset.

renderer.render(stage);
};

document.addEventListener('mousemove', updatePosition.bind(rec));

• thank you but I must keep the position. In this context the pivot is used for the z Index. the position is the position of the sprite on the map, and pivot are the z Index. this can help to understand youtu.be/MpZD0E0_iKI – jon May 3 '18 at 11:46
• If you have an important constraint like that, please always describe it in your question. Users here are not mind-readers, and know nothing about your project except what you tell us explicitly. – DMGregory May 3 '18 at 11:49
• you right, forgive me my forgetfulness. – jon May 3 '18 at 11:59