The Daily Click ::. Forums ::. Klik Coding Help ::. Problem with 360 degree formula
 

Post Reply  Post Oekaki 
 

Posted By Message

Louis Moon



Registered
  24/10/2002
Points
  116
1st December, 2004 at 18:26:13 -

I was following RyGuyX's 360 degree shooting tutorial. I was fine with the relative X distance, relative Y distance, and total distance (counters in my level for testing showed they were working right). When I got to the part about getting an angle of an object relative to another, I ran into a brick wall. My test counter always shows either 0, 180, or 5280. These are my events-

ALWAYS SET ALTERABLE VALUE A (OF GUN) TO- ArcSin( "Advanced Math object", Value B( "crosshair" ) / Value C( "crosshair" ) ) * ( 180000 / 3142 )

X POSITION (OF CROSSHAIR) >= X POSITION (OF GUN) THEN SET VALUE B (OF GUN) TO ALTERABLE VALUE A (OF GUN)

X POSITION (OF CROSSHAIR) < X POSITION (OF GUN) THEN SET ALTERABLE VALUE B (OF GUN) TO (180 - ALTERABLE VALUE A (OF GUN))

I used 180000/3142 as a substitute for pi which was in the formula. See anything wrong? BTW, all the relative distances were stored in the crosshair's alterable values. Any help would be appreciated.

 
n/a

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
1st December, 2004 at 20:16:38 -

At first glance, one problem is that (180000 / 3142) is nowhere near pi - it's about 57.288. A better approximation would be 22/7.

 
http://www.davidn.co.nr - Games, music, living in America

Louis Moon



Registered
  24/10/2002
Points
  116
2nd December, 2004 at 09:02:53 -

Changed it to that, did the same sort of thing.

 
n/a

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
2nd December, 2004 at 10:03:00 -

In that case it's possibly a rounding error - try adding decimal places to the end of the 22 and 7.

 
http://www.davidn.co.nr - Games, music, living in America

Long John Kickbag



Registered
  26/08/2002
Points
  148
2nd December, 2004 at 11:21:05 -

180000/3142 is the (approximate) ratio of degrees to radians.

 
Resize! - www.clicksplat.com/comparison.html

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
2nd December, 2004 at 12:34:37 -

Ah, sorry - my mistake, then. The second idea still stands - add decimal points so that MMF computes the decimal places as well.

 
http://www.davidn.co.nr - Games, music, living in America

Louis Moon



Registered
  24/10/2002
Points
  116
2nd December, 2004 at 14:39:53 -

Unfortunately, I use TGF. Any other ideas, considering this?

 
n/a

Long John Kickbag



Registered
  26/08/2002
Points
  148
2nd December, 2004 at 17:57:21 -

Make sure you changed the decimal offset to at least 2. Also try altering the expressions so that multiplications are performed before divisions, that'll reduce rounding errors.

 
Resize! - www.clicksplat.com/comparison.html

Louis Moon



Registered
  24/10/2002
Points
  116
2nd December, 2004 at 18:20:47 -

I realized that when I tried using 22\7, I forgot the 180\ bit. Put it in, still didn't work. I don't see anywhere in any of the expressions where you could make multiplications before divisions (and still come out with the same result). Any other ideas?

Oh I forgot- setting the decimal offset to 2 didn't seem to do anything.

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click