I'd like to know how to correct the position and draw it in the same way as when two objects collide with each other in a 2D game.
In the case of a line segment that cannot be considered by points and line segments, find the cross coordinates, move them to the location, and then insert them in the opposite direction to the direction of movement なおSquare or rectangle is not a line segment.
Think of it as a square and have a vector with movement and direction at the four corners of the square to determine the hit between the line segment in that direction and the line segment of the object. 来るI still don't know how to calculate the collision coordinates.
In the case of a line segment that cannot be taken into account by points and line segments, find the cross coordinates and move them to that location, then insert them in the opposite direction of the size movement *Squares and rectangles are not line segments, so this cannot be implemented.
Think of it as a square and have a vector with movement and direction at the four corners of the square, and implement the hit determination between the line segment in that direction and the line segment of the object. 来るI still don't know how to calculate the collision coordinates.
When two moving objects collide in the same way as in the real world.In reality, I want to correct the position of objects in the same position.
I want to correct it to the same position as when two objects collide in the real world, but in order to correct the amount of immersion, which point should I correct the coordinates from when I collide?
c++
As far as I know, it is common to think separately about the "determining if two objects are colliding" and the "calculating if they collide with each other."
When considering collisions between rectangles, it is important to note that they may rotate unlike collisions between pawns.You have to determine if the inclined rectangles collide with each other, and it may start to rotate after the collision.It's not that easy to figure out how to calculate in this case."I don't think the ""collision coordinates"" that the questioner said will solve the problem."
As far as I know, Box2D, a library that can perform two-dimensional physical simulations, is easy to learn with public implementations and explanatory articles.
In Japanese, I think a search word like "physical engine self-made" is convenient.I haven't read it in detail, but I'll try to link some articles that I found.
© 2024 OneMinuteCode. All rights reserved.