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 3877846
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:32:42+00:00 2026-05-19T22:32:42+00:00

I hav bee struggling with a collision response method, im writing in actionscript 3

  • 0

I hav bee struggling with a collision response method, im writing in actionscript 3, for a long time now, and I am hoping someone can explain what this code means, for I have only modified it. I did not write it from scratch. also I am using the Collision Detection Toolkit to find where the collisions are happening.
What im trying to do is make it so that Ball (which is the object that you move around the screen with your keyboard) hit’s a wall or object it will not go through the wall or object.

my understanding of this is that you are finding the angle that the collision is happening at and then you need to find the angle which is adjacent which is the new vector and push back the object by however much it’s overlapping, but I dont understand how this function works for instance what is

vx0:Number = ball.vx * cos + ball.vy * sin;

finding?. in addition I dont want the ball to accelerate I want it’s velocity to be constant until it hits an object. also would it be faster to search through this array backwards?

— I appreciate any one who takes the time to try and help me with this, and im sorry if I have some misspellings.

     for(i = 0; i < collisions.length; i++) 
        {
            var collision:Object = collisions[i];

            var angle:Number = collision.angle;
            var overlap:int = collision.overlapping.length;
            var ball:Ball = collision.object1;

            var sin:Number = Math.sin(angle);
            var cos:Number = Math.cos(angle);

            var vx0:Number = ball.vx * cos + ball.vy * sin;
            var vy0:Number = ball.vy * cos - ball.vx * sin;

            vx0 = .4;
            ball.vx = vx0 * cos - vy0 * sin;
            ball.vy = vy0 * cos + vx0 * sin;

            ball.vx -= cos * overlap / ball.radius;
            ball.vy -= sin * overlap / ball.radius;
        }
  • 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-19T22:32:43+00:00Added an answer on May 19, 2026 at 10:32 pm

    Keith Peters has a wonderful book called Foundation Actionscript 3.0 Animation: Making Things Move.

    Chapter 9 covers the topic you’re having trouble with.

    This page in particular should be of assistance.

    http://books.google.ca/books?id=nzyu5TytMEUC&lpg=PP1&dq=actionscript%203.0%20animation&pg=PA235#v=onepage&q&f=false

    He uses home-baked, trigonometric collision testing, but you should be able to replace his distance checking with the functions and properties built into Collision Detection Kit.

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

Sidebar

Related Questions

No related questions found

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.