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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:54:43+00:00 2026-06-03T18:54:43+00:00

function ProcessCollisions():void{ //respawn if player died if(percentHP == 0){ Player.x = _startMarker.x; Player.y =

  • 0
function ProcessCollisions():void{

//respawn if player died
if(percentHP == 0){
    Player.x = _startMarker.x;
    Player.y = _startMarker.y;
    Gun.x = Player.x;
    Gun.y = Player.y - 45;
    _boundaries.x = 0;
    _boundaries.y = 0;
    Player.vy = 0;
    currentHP = maxHP;
}
//when Player is Falling
if(Player.vy > 0){
    //Otherwise process collisions of boundaires
        var collision:Boolean = false;
        if(_boundaries.hitTestPoint(Player.x, Player.y, true)){collision = true;}
        if(collision == true){
            while(collision == true){
                Player.y -= 0.1;
                Gun.y -= 0.1;
                collision = false;
                if(_boundaries.hitTestPoint(Player.x, Player.y, true)){collision = true;}
            }
            trace("Collision is " + collision);
            currentHP -= Player.vy * .1
            Player.vy = 0;
            Gun.vy = 0;
            JumpCount = 0;
        }
}

}

My Collision processing is above…I have this issue where Collision boolean is constantly returned as false even when I am colliding with an object within _boundaries. It creates a shaking effect onto my player as the while loop constantly pulls the player out of the boundary and the player seemingly falls into it infinitely…Can anyone help with this? Also in a Frame handler called by an Enter Frame Timer I make some more changes to Player.vy, that is included below

function FrameHandler(e:Event):void{
    //If Statements to slow character
    if(aKeyPressed == false && Player.vx > 0){
        Player.vx -= 1
    }
    else if(dKeyPressed == false && Player.vx < 0){
        Player.vx += 1
    }
    //Gravitates Player
     Player.vy += 1.5;
    //Controls arrays of bullets for Weapons
    //Process Collisions
    ProcessCollisions();
    //Scroll Stage
    scrollStage();
    //Attunes for multiple keypresses
    MultipleKeypresses();
    //Keeps Gun attached to Players Arm
    Gun.x = Player.x
    Gun.y = Player.y - 45;
    if(sKeyPressed){
        Gun.y = Player.y - 13;
        Gun.x = Player.x + 8;
    }
    //Checks Health
    updateHealthBar()
    //move Player and Gun
    Gun.y += Player.vy;
    Gun.x += Player.vx;
    Player.x += Player.vx;
    Player.y += Player.vy;

}
  • 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-06-03T18:54:44+00:00Added an answer on June 3, 2026 at 6:54 pm

    (1) trace("Collision is " + collision); is only executed once you’ve left your while(collision == true) loop, so you will ONLY ever see "Collision is false" on your trace.

    (2) When you detect a collision, Player.y -= 0.1; moves the player upward in steps of 0.1, so you’ll never get further than 0.1 away from the thing you collided with.

    Then, having set Player.vy=0, it gets reset in the next frame to 1.5 (by Player.vy += 1.5;), which increments Player.y by 1.5… which will always result in another collision!

    EDIT: The way to fix this depends on what effect you want: if you want the player to bounce off the object like a trampoline, you can replace Player.vy = 0; with Player.vy = -Player.vy;.

    Alternatively, to make the player land on the object and stay there, you can test for a potential collision before updating Player.y. Something like this:

    //move Player and Gun, if we're not about to collide
    if(_boundaries.hitTestPoint((Player.x+Player.vx), (Player.y + Player.vy), true)==false){
        Player.y += Player.vy;
        Gun.y += Player.vy;
        Player.x += Player.vx;
        Gun.x += Player.vx;
    } else {
        // we're about to collide: stop moving
        Player.vy = 0;
        Player.vx = 0;
    }
    

    This isn’t a perfect solution: it may make the player land some distance from the object, depending on vy and vx, so a refinement would be to work out the exact point of impact, and move there before stopping.

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

Sidebar

Related Questions

function test() { var id = 123; var id12 = 'abcd'; var childDiv =
function getsession(){ var data = $.get('../session', function(data) { return data; }); return data; }
function SendInfo(href) { var subject= Some information; var body = I thought you might
function convertDates($timestamp) { return date('Y-m-d', $timestamp); } $days = array(); //storing databases php time();
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
function main() { Hello(); } function Hello() { // How do you find out
function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError,
function holiday_hitlist($tablename, $hit_user){ global $host, $user, $pass, $dbname; $link = mysql_connect($host, $user, $pass, $dbname);

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.