Jump to content
  • Advertisement
Sign in to follow this  
football94

Delete BoundingSphere

This topic is 2105 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

 Hi guys

Ive been testing out the collision detection portion of my project where a I have a bullet(billboard,point sprites,etc..) coming from a model colliding
with a red sphere(picture below) the problem that Im having is getting the boundingspheres from the bullet and the red sphere to disappear after
collision has taken place(picture below), if anyone has any advice it would be much appreciated.
 

 

                                                                         Thankyou

 

 

 

 

 

picture before the red sphere is hit with bullet

 

[attachment=18326:10 9 2013 4 05 09 PM.jpeg]

 

 

 

picture after collision. the red ball is gone, but the collision spheres from the bullet or the red ball wont disappear

 

[attachment=18327:10 9 2013 4 06 24 PM.jpeg]

 

 

 

 

 

 

This is a modified version of the code taken from the riemers website(link below)

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Point_sprites.php
 

 private void UpdateBulletPositions(float moveSpeed)
        {
            
           
                        for (int i = 0; i < bulletList.Count; i++)
                        {

                            pos = worldMatrix12.Translation;

                            Bullet currentBullet = bulletList[i];
                            MoveForward(ref currentBullet.positionfire, currentBullet.rotationfire, moveSpeed * 2.0f);
                            bulletList[i] = currentBullet;


                          

                            if (ball1.isActive)
                            {
                                
                                bulletSphere = new BoundingSphere(currentBullet.positionfire, 3.05f);

                                bbaall = new BoundingSphere(pos, ball1.Model.Meshes[0].BoundingSphere.
                                                     Radius *
                                                     3.05f);



                            

                                if (collision(bulletSphere, bbaall))
                                {
                                    bulletList.RemoveAt(i);
                                    i--;

                                   
                                   

                             }


                       }

                       
                }  
 
        }



                //COLLISON DETECTION METHOD
                bool collision(BoundingSphere b, BoundingSphere a)
                {
                    if (b.Intersects(a)) 
                    {
                        ball1.isActive = false;
                         soundHyperspaceActivation.Play();
                        return true;
                    }
                     return false;
                  }
    

Thanks again

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!