Opinions on solving a gaming platform / background conflict

Imagine the following scenario: I have a level whose physical structure is built from a collection of bounding rectangles, combined with a preliminary raster background. My actors, including the player’s character, have their own bounding box. If the actor manages to get stuck inside the level block, partially or otherwise, he will need to be moved again so that he is on the same level with the block.

The unverified technique that I came up with during the biodegradation is as follows:

If you find that the exponent field intersects the level field, determine where the center points of each rectangle are. If the actor’s center is higher than the level field, move the actor so that the lower part of the rect actor is flush with the upper part of the rect level, and vice versa if it is lower. Then do a similar thing horizontally.

Opinions on this? Suggestions for best practices?

In fact, bounding boxes are XNA BoundingBoxes with their Z-range from -1 to 1, but this is still a 2D gameplay.

+3
source share
4 answers

N Tutorials? , . ( N . , , ( ) .

- , SAT, .

( , , , Game Developers, realtimecollisiondetection.net, essentialmath.com, / , GDC. GJK , , , " " Minkowski , , .)

+5

, "" , - . - , , .

AABB ( ) .

( 2D AABB, , , .)

, . - ( , ).

N , . AABB.

+1

. . ...

. , . , , .

, " ", , .

, , . , -, .

, , .

0

Another possible approach is that instead of waiting for a collision and then moving out of it, check for possible collisions before moving objects, and if a conflict occurs, move the player only to the edge of the block.

Ie, contrasts with how Adventure collides with walls: http://www.youtube.com/watch?v=I6-zN_eaRd8 like most NES games collide with walls.

0
source

Source: https://habr.com/ru/post/1750363/


All Articles