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

  • Home
  • SEARCH
  • 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 933525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:50:54+00:00 2026-05-15T20:50:54+00:00

I have created a collision class to detect collisions using pixels. In my class

  • 0

I have created a collision class to detect collisions using pixels. In my class I’ve also developed some functions for determining the collsion angle. Based on this I created some examples:

http://megaswf.com/serve/25437/

http://megaswf.com/serve/25436/

(Space to change gravity, right/left to give some speed to the ball.)

As you will probably notice, there are strange things that happen:

  • When the ball speed is very low
  • When the direction of the ball is
    almost tangent to the obstacle.

collision http://img514.imageshack.us/img514/4059/colisao.png

The above image shows how I calculate the collision angle.
I call the red dots the keypoints. I search for a maximum number of keypoints (normally 4). If I find more then 2 keypoints, I choose the 2 farthest ones (as shown in one of the blue objects). Thats how I then find the normal angle to where in the surface the object collided. I don’t know if this is an obsolete way of doing things.

based on that angle, I rotate the speed vector to do the bouncing.

The piece of code to do the maths is here:

static public function newSpeedVector(speedX: Number, speedY: Number, normalAngle: Number): Object{
            var vector_angle: Number = Math.atan2(speedY, speedX) * (180/Math.PI);
            var rotating_angle: Number = (2*(normalAngle - vector_angle) + 180) % 360;
            var cos_ang: Number = Math.cos(rotating_angle/DEGREES_OF_1RAD);
            var sin_ang: Number = Math.sin(rotating_angle/DEGREES_OF_1RAD);
            var final_speedX: Number = speedX * cos_ang - speedY * sin_ang;
            var final_speedY: Number = speedX * sin_ang + speedY * cos_ang;

            return {x_speed: final_speedX, y_speed: final_speedY};
        }

This is how the new speed vector is calculated…

My question is, has anyone faced this kind of problem or has some idea on how to avoid this from happening?

  • 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-15T20:50:54+00:00Added an answer on May 15, 2026 at 8:50 pm

    Without seeing your code, this is the best I can provide.

    Collision physics should have some velocity threshold that is considered “stopped”. That is, once the velocity gets small enough you should explicitly mark an object as stopped and exempt it from your collision code. This will help stabilize slow moving objects. Trial and error is required for a good threshold.

    When a collision happens, it is important to at least attempt to correct any inter-penetration. This is most likely the reason why tangent collisions are behaving strangely. Attempt to move the colliding object away from what it hit in a reasonable manner.

    Your method of determining the normal should work fine. Game physics is all about cheating (cheating in a way that still looks good). I take it rotation and friction isn’t a part of what you’re going for?

    Try this. You have the contact normal. When you detect a collision, calculate the penetration depth and move your object along the normal so that is isn’t penetrating anymore. You can use the two points you have already calculated to get one point of penetration, you’ll need to calculate the other though. For circles it’s easy (center point + radius in direction of normal). There are more complex ways of going about this but see if the simple method works well for you.

    I have read and recommend this book: Game Physics Engine Development

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

Sidebar

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.