Jump to content

Predictive collision and the best way to stop a moving object at an exact position?


Cyclone112
 Share

Recommended Posts

I have a top-down game where I want most objects aligned to tiles. They can be moved(by having a velocity applied to them) but when they do they need to end exactly within a tile when they are stopped.

Let's say I have a sprite that is moving across the screen and it detects that the next tile it will try to enter is occupied by some other object. In that scenario I would like to manually stop the sprite at exactly the location of the tile it's in.

Currently I have collision on blue and red in the picture and blue would then be manually aligned at the previous tile which looks bad animation wise as it sort of jumps backwards. So what I think I need is a sort of predictive method where before blue enters the next tile it checks if that tile is occupied and if so stops.

Any suggestions on the best way to handle this?

sprite_stop.png.6604ae022767315455f9a92af62c0d5a.png

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...