# Trigonometry - rotate slowly to the mouse

**URL:** https://forum.kirupa.com/t/trigonometry-rotate-slowly-to-the-mouse/173048
**Category:** Uncategorized
**Created:** [December 20, 2005, 6:08pm UTC](https://forum.kirupa.com/t/trigonometry-rotate-slowly-to-the-mouse/173048 "2005-12-20T18:08:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![NinoScript](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ninoscript/32/1484_2.png) [@NinoScript](https://forum.kirupa.com/u/NinoScript)
#### Post date: [December 20, 2005, 6:08pm UTC](https://forum.kirupa.com/t/trigonometry-rotate-slowly-to-the-mouse/173048/1 "2005-12-20T18:08:35Z")

</div>

ive got this problem, i know how to check the angle between my object and the mouse, but i dont know how to make it rotate slowly to it…

i tried this codes:

```auto

//first method:
onClipEvent (enterFrame) {
	this._rotation = (Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x))*180/Math.PI;
}
//(this one doesnt have slow movement, it was just to know my code was working to detect the mouse angle)

```

```auto

//second method:
onClipEvent (enterFrame) {
	this.targetRotation = (Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x))*180/Math.PI;
	if (this.targetRotation-this._rotation>6) {
		this._rotation += 6;
	} else if (this.targetRotation-this._rotation<-6) {
		this._rotation -= 6;
	}
}

```

```auto

//third method:

onClipEvent (enterFrame) {
	this.targetRotation = (Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x))*180/Math.PI;
	if ((this.targetRotation<0 ? this.targetRotation+360 : this.targetRotation)-this._rotation>6) {
		this._rotation += 6;
	} else if ((this.targetRotation<0 ? this.targetRotation+360 : this.targetRotation)-this._rotation<-6) {
		this._rotation -= 6;
	}
}

```

```auto

//fourth method:
onClipEvent (load) {
	this.rot = this._rotation+360;
}
onClipEvent (enterFrame) {
	this.targetRotation = (Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x))*180/Math.PI;
	if (this.targetRotation+360-this.rot>6) {
		this.rot += 6;
	} else if (this.targetRotation+360-this.rot<-6) {
		this.rot -= 6;
	}
	this._rotation = this.rot;
}

```

none of them worked 😛  
can somebody help me??
