pstrejczek Posted July 1, 2018 Share Posted July 1, 2018 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? Quote Link to comment Share on other sites More sharing options...
8bitdna Posted July 2, 2018 Share Posted July 2, 2018 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? Quote Link to comment Share on other sites More sharing options...
pstrejczek Posted July 3, 2018 Author Share Posted July 3, 2018 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.