[project1dev] Re: Project1 - SVN Update 403

  • From: Alan Wolfe <alan.wolfe@xxxxxxxxx>
  • To: project1dev@xxxxxxxxxxxxx
  • Date: Tue, 28 Jul 2009 12:48:30 -0700

there might be a better way to do this but here's what i would do.

let's say CA is current angle and DA is destination angle and let's assume
they are between 0 and 360.  Let's also say MaxRotate is how much you can
rotate each frame (pseudo code below is C++ style)

//calculate the distance between the angles
AngleDist = abs(CA-DA) % 360;

if(AngleDist > 180)
  AngleDist = 360 - Angle;

//if the 2 angles are close enough, just set the current rotation to the
destination rotation
if(AngleDist < MaxRate)
  CA = DA;
//otherwise it's going to take moer than one frame to get there
else
{

  //figure out if it's shorter to go positive or negative in rotation (ie
left or right)
  if(CA <= DA)
  {
    if(DA-CA < 180)
      Direction = 1;
    else
      Direction = -1;
  }
  else
  {
    if(CA-DA < 180)
      Direction= -1;
    else
      Direction = 1;
  }

  //move the current angle
  CA = CA + MaxRate * Direction;
}


On Tue, Jul 28, 2009 at 12:30 PM, Apache User
<dhapache@xxxxxxxxxxxxxxxxxxx>wrote:

> User:korgath
>
> Message: kitty upgrade
> Fixed a bug I created that made the kitties choppy
> Kitties no longer pop when jumping
>
> Alan - I am having issues with the smooth looking you suggested. Can you
> point me in the right direction? I was thinking something like having it
> store the old angle before creating a new angle. then comparing the
> difference but then I'm not sure what to do with the difference to make it
> rotate properly. Uploaded kitty2 with my beta changes
>
> <Files Changed>
> U   Scripts/Enemies/kitty.lua
> A   Scripts/Enemies/kitty2.lua
>
>
>

Other related posts: