Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed collision detection when a bullet passes through a bot. #14

Closed
wants to merge 1 commit into from

Conversation

dynajoe
Copy link

@dynajoe dynajoe commented Jul 16, 2013

The algorithm uses the projection of the vector AB (from bullets
previous location to center of bot) onto AC (from bullets previous
location to new location). If the distance from the projection to the
center of the bot is less than the radius of the bot somewhere along the
way the bullet passed through the bot, resulting in a hit. If the
magnitude of this projection is greater than the magnitude of the
bullets vector then the bullet has not passed through the target
because the bullet has not yet traveled far enough.

Test cases have been added that describe the above.

Here's a graphic representation of the algorithm:

projection

This should be thoroughly reviewed.

@dynajoe
Copy link
Author

dynajoe commented Jul 16, 2013

This is related to #13

The algorithm uses the projection of the vector AB (from bullets
previous location to center of bot) onto AC (from bullets previous
location to new location). If the distance from the projection to the
center of the bot is less than the radius of the bot somewhere along the
way the bullet passed through the bot, resulting in a hit. If the
magnitude of this projection is greater than the magnitude of the
bullets projection then the bullet has not passed through the target
because the bullet has not yet traveled far enough.

Test cases have been added that describe the above.
@dynajoe
Copy link
Author

dynajoe commented Jul 16, 2013

There seems to be an issue when the target bots center is on a wall.

@dynajoe dynajoe closed this Aug 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant