Sign in to follow this  
pstrejczek

Quite complicated collision detection

Recommended Posts

So .. I'm working on this little orbiting game and I have a problem with collision detection.

I have some sprites within the container. The container is rotating (so the sprites are also rotating). One of the sprites is an Arc.

What I want to do is to detect a collision of my player sprite with that arc. Any ideas how to achieve that?

Share this post


Link to post
Share on other sites

The built in physics engine has support for collision detection via circles as per:

https://www.panda2.io/examples#physics-Circle

So if you had your player sprite using a physics shape as well you could detect a collision between that and the circle.  After that you could qualify it further to the arc by using a known state.  So say your arc is 45 degrees and always starts at a given angle you'll know if its collided by checking its current angle vs it starting one when then circles collide.

Does that kind of make sense?

Share this post


Link to post
Share on other sites

That's what I have actually done - but without the physics engine. I'm still having some problems with the angles. I don't know if this has something to do with the container rotation taking place in update function in a different class than the one I'm doing collision checks. It kinda works - but sometimes doesn't :)

What I do is I check angles for the arc endpoints and then the angle of a vector from player position to the container center. Sometimes it looks like it hits out of the arc, but when I check values which are console.logged I can see it is not.

 I'm still looking for maybe a better solution

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.