Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Having some problems with object collision, please help me =/

This topic is 5685 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

This has really been bugging the hell out of me for the last couple days. Here's my situation: I tried making a version of Slime Volleyball from http://diddly.com/slime and it's been going fine until I get to some object collision. Here's my code for detecting ball/slime collision (slimes are semicircles, the ball is a circle):
//Do some other collision checks

        //Slime check

	//If the ball's X value, fX, is less than zero, then

	//it is on the left side of the net check the left slime

		//Rough check of distance between slime/ball

			//Get the angle in radians of the collision

			//Get the magnitude of the ball speed

			float fMag=Distance(fXVelocity/1.5f,0,fYVelocity,0);
			//Determine the ball's new velocity

			//X velocity is 1.5x Y velocity


			//I don't know why I have to check this, but it's the only way it works

			//Check when the ball is below the slime and will collide with the slime

			else if(fY+fRadius<pSlime[0]->fY && fX>pSlime[0]->fX-pSlime[0]->fRadius && 
				fX<pSlime[0]->fX+pSlime[0]->fRadius && 
				//=================PROBLEM HERE================

				//This is the closest I can get it to working


				//Set Y Velocity to a certain value because I can't get it to work otherwise

				//fYVelocity=-abs(fYVelocity);  <--- this doesn't work

				//Set YVelocity

			//No collision, so slow down the ball Y Velocity

//iTimeDifference is how much time elapses every frame

//0.000005f is the acceleration due to gravity

        //Check other side

Alright, most of this works fine EXCEPT for the part where it checks if the ball is underneath the slime. I was forced to put in that forced YVelocity because I couldn't get it to work any other way. What happens if I don't do this is the ball just shoots up through the slime as if it had collided with the top part of the slime. Can anyone please help me? Here's a link in case you want to check it out: Slime Volleyball [edited by - Kaezin on March 25, 2003 5:10:10 PM]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!