Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6760737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:05:58+00:00 2026-05-26T14:05:58+00:00

I have this problem: there is this enemy which rotates to my player. While

  • 0

I have this problem: there is this enemy which rotates to my player. While "orbiting" the enemy with my player I can see that the enemy is rotating towards my player.

And then the enemy suddenly turns around 360 degrees and facing to my player again. I don’t know why it does this strange 360 degree turn but it happens every time when I orbit the enemy for a few seconds. I don’t know where the problem might be.

tempEnemy.dX = tempEnemy.x - player.x;
tempEnemy.dY = tempEnemy.y - player.y;
                        
tempEnemy.rotateTo = toDegrees(getRadians(tempEnemy.dX, tempEnemy.dY));
                        
                        
                        
if(tempEnemy.frame < 0) tempEnemy.frame += 360;
if(tempEnemy.frame > 359) tempEnemy.frame -= 360;
                        
                        
tempEnemy.trueRotation = int((tempEnemy.rotateTo - tempEnemy.frame) / tempEnemy.rotateSpeed);
                        
tempEnemy.vX += (player.x - tempEnemy.x) / tempEnemy._speed;
tempEnemy.vY += (player.y - tempEnemy.y) / tempEnemy._speed;
         
tempEnemy.vX *= tempEnemy.decay;
tempEnemy.vY *= tempEnemy.decay;

Update:

private function toDegrees(radians:Number):Number
    {
        var degrees:Number = Math.floor(radians * 180 / Math.PI);
        //trace (degrees);
        return degrees;
    }

private function getRadians(deltaX:Number, deltaY:Number):Number
    {
        var radian:Number = Math.atan2(deltaY, deltaX);
        
        if (deltaY < 0)
        {
            radian += (2 * Math.PI);
        }
        return(radian);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:05:59+00:00Added an answer on May 26, 2026 at 2:05 pm

    Without seeing your getRadians function, perhaps you’re passing 360° calculating a reflex angle?

    Maybe something like:

    var degrees:Number = Math.atan2(tempEnemy.y - player.y, tempEnemy.x - player.x) * 180 / Math.PI;
    var delta:Number = degrees - tempEnemy.rotation;
    
    while (delta <= -180)
        delta += 360;
    while (delta > 180)
        delta -= 360;
    

    Compensate degrees with the resting angle of your enemy display object design.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem that when there is an OpenGL application I am working
I have this problem which made my scratch my head: Is there a way
i have this problem that i can't solve for days now...here is my code.
I have been researching this problem and while there's lots of posts on various
I have a problem where I have some html like this <p>There is the
I have this problem I've been trying to tackle for a while. I have
I have this problem. I want to detect if there is not a session
I have this problem that I probably understand but don't know how to handle,
I have searched on google and stackoverflow for this problem there are several questions
I have this problem to solve that I have no idea how to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.