Forgot your password?
Or sign in with one of these services
This topic is now archived and is closed to further replies.
, December 12, 1999 in General and Gameplay Programming
This topic is 6735 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.
What you're going to do is essentially create a vector(line) between where the object is, and where it's going to end up. Then you check to see if that line intersects any other objects. If it does, you probably have a collision, though the tests may get more in depth depending on how accurate you want your collision code to be.
What i was thinking i needed to do was break down the speed and do collision checks every few pixels. Example
ball is moving at 16 pixelsi would take the ball break the 16pixels moved down to 4 collision checks 1 for each 4 pixels moved.(this would help reduce the amount of checks needed and still be pretty acurate.)
My problem was implementing something like this.
ex.:Let say you have a sqare, corner 1 is top left, 2 is top right, 3 is bottom left and 4 is bottom right.If your sqare travel in a direction (45 degre angle) you can :1- (if you have a relatively small square) trace a single vector (from point 3 to destination passing by point 2) and checking collision against this vector.
2- (for larger ones) 2 vector from point 1 and point 4 going to point 1 and 4 at the destination.
Once you have the collision on the vector, you can then calculate the 'when did it happened' to see if the object would have collided or just cross path ...
TimeCollisionOccured = VectorLengthAtCollision / VectorTotalLength(Does not really calculate the time but the % of movement completed...)
(sorry for any gram. or vocab. error ... still learning english)
Of course, it always depends at how precise you want your collision to be.
Bingo! That is the safest and most accurate method. It is even more accurate than a pixel-by-pixel approach because the collision point can be a floating-point coordinate.
Anyway, maybe that was confusing, but have fun anyway.
Started Thursday at 02:01 PM
Started Thursday at 01:17 PM
Started Wednesday at 12:01 PM
Started May 15
Started May 15
Participate in the game development conversation and more when you create an account on GameDev.net!