COLLISION COORDINATE OBTAINED BY COLLISION OF A PLURALITY OF MOVING OBJECTS IN 2D GAME

Asked 1 years ago, Updated 1 years ago, 320 views

Question details

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.

Conditions

  • Rectangular, square, etc.
  • I would like to assume that the movement volume is uncertain due to mutual movement, the direction of movement is uncertain, and that it moves through at high speed.
  • Three or four objects move in an uncertain direction simultaneously in one scene

Experiments and trials

  • 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.

What do you want to do

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.

What do you want to know

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?

Enter a description of the image here

c++

2022-12-30 22:48

1 Answers

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.


2022-12-31 10:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.