Jump to content
  • Advertisement
Sign in to follow this  

Collide and Slide

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

Hope this is the right forum. I am trying to have the ship, once it has hit the wall of blocks, to slide along the edge of the wall with the following code. http://img175.imageshack.us/img175/525/slides.png
		object *obj = ps->tiles;
		float r0 = ps->tiles->get_radius(),
			r1 = get_radius();
		coord temp_coord = pos + (direction*speed);
		if((temp_coord.x + r1 > obj->pos.x - r0) && (temp_coord.x - r1 < obj->pos.x + r0) &&
			(temp_coord.y + r1 > obj->pos.y - r0) && (temp_coord.y - r1 < obj->pos.y + r0)){
			if(pos.y + r1 < obj->pos.y - r0 || pos.y - r1 > obj->pos.y + r0)
				dir.y = 0;
			if(pos.x + r1 < obj->pos.x - r0 || pos.x - r1 > obj->pos.x + r0)
				dir.x = 0;


It works sort of. On the 'Y' axis it'll slide up fine but when sliding down it'll bump(stop and continue, stop and continue etc), on the 'X' axis it'll do this for both directions. Any ideas why this could be happening? Thanks.

Share this post

Link to post
Share on other sites
The collision detection makes sense, but not the collision response. Looks like it would never slide properly.

Share this post

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

  • 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!