From: Stefan Rusterholz Date: 2008-02-15T20:39:26+09:00 Subject: Re: Making an object follow another object - FAIL! Lasse Svensson wrote: > My question is a mathematical one, here we go: > > As you can see here " angle2 = (atan((y2pos-ypos) / > (x2pos-xpos)))/(PI/180)" I determined the angle of the second object by > calculating the angle between the two objects. It works as long as > angle2 is less than 90 or more than 270, but if it gets between there it > breaks away. Compare Math.atan and Math.atan2. Math.atan2 relieves you from doing a manual branching depending on the angle. Regards Stefan -- Posted via http://www.ruby-forum.com/.