Announcement

Collapse
No announcement yet.

ATan2? Dose UT2k4 have it or not???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    ATan2? Dose UT2k4 have it or not???

    I am working on a real time stratagy game.(trying)
    Right now im working on just simply moveing units.
    I was thinking just to get units to look ware i want them to, i woud do somthin like this.

    Y2=LookAtY-Y
    X2=LookAtX-X
    LookAngle=ATan2(Y2,X2)

    or in other words


    local rotator rot;
    local float y1;
    local float y2;
    local float x1;
    local float x2;
    local float dy;
    local float dx;
    local float phy;


    y1=Location.Y;
    x1=Location.X;
    dy=y2-y1;
    dx=x2-x1;
    phy = ATan2(dy,dx);

    rot.yaw = phy;
    SetRotation(rot);

    it errors:

    wen i do atan with out the 2 it dose work. i know atan2 is amore acurat ver of atan dose it matter?
    (im only 13 i dont realy know wat eather wer 3 hrs ago)


    so basicly
    1. how do i get atan2 to work
    2. and or can i just use ATan

    #2
    Re: ATan2? Dose UT2k4 have it or not???

    Originally posted by UTmoder-wana-be
    2. and or can i just use ATan
    It all depends on what you plan to do with it.
    If your programs involves multiplying the LookAngle by big numbers, then having less precision from the start could really be a problem.

    But idk how to make it work

    Comment


      #3
      There is only Atan.

      Comment


        #4
        I think ATan() actually is ATan2() in UT2004.

        Comment


          #5
          Ok thanks.

          Ile try just useing ATan and go on with the code. If anything gose rong ile post again.
          Thanks.

          Comment


            #6
            To test math calculations, you might want to whip up a quick commandlet. There's a decent example on the Wiki, and if you want I can post a documented commandlet "template" when I get home tonight.

            Comment

            Working...
            X