The Daily Click ::. Forums ::. Klik Coding Help ::. 360° "Look at"
 

Post Reply  Post Oekaki 
 

Posted By Message

nim



Registered
  17/05/2002
Points
  7234
14th February, 2008 at 19:08:22 -

I got this to work once before with TGF/Advanced Math but for some reason I can't get it working in MMF2.

Here's what I have at the moment:
Set rotation to ... ATan((Y("Active" )-YMouse)/(X( "Active" )-XMouse))

(rotate an object to "always look at the mouse")

 
//

Dustin Gunn

Gnarly Tubular Way Cool Awesome Groovy Mondo

Registered
  15/12/2004
Points
  2659

Game of the Week WinnerKlikCast StarVIP MemberI'm on a BoatGOTW Winner Oct 2010Kliktober Special Award Tag
15th February, 2008 at 14:18:56 -

Advanced direction object is great for this.

Set angle to Direction( "Advanced Direction Object", X( "object" ), Y("object"), Xmouse , Ymouse)

 
n/a

nim



Registered
  17/05/2002
Points
  7234
15th February, 2008 at 18:57:07 -

Thanks very much, that works perfectly.

Although, I don't like to use extensions as a crutch if there's a way to code something manually, so I'm curious to know what's wrong with my formula. I also tried converting it from radians to degrees (/180*pi) but it didn't help.

 
//

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
16th February, 2008 at 05:14:17 -

It could depend on what event you used that formula. Remember that your formula only works correctly on the first quadrant of the coordinate system. Atan always returns a value between -90 and +90.

Edit: Oh right, you should also stuff a *1.0 in everywhere, otherwise the division works with integers.

Image Edited by the Author.

 
This space is for rent
   

Post Reply



 



Advertisement

Worth A Click