0
\$\begingroup\$

This question already has an answer here:

I am attempting to create an effect in a game that is identical to the effect I've shown in the attached gifs. Essentially, the character, when they are running or walking and hit an object that is stationary, if it's possible, (meaning there is a valid path for continuation) they should glance off the side of said object and keep going.

In this first GIF I am only holding the UP directional key, notice how the character glances to their right:

Glancing to the right


In this second GIF I am only holding the DOWN directional key, notice how the character glances to their left:

Glancing to the left


In this third GIF I am only holding the UP directional key, notice how the character glance first to their left and then to their right:

Glancing to the left and right


Could someone describe the process that I would need to follow in order to do this type of collision detection into redirection?

\$\endgroup\$

marked as duplicate by Josh Oct 10 '14 at 5:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ I think there's a huge amount of ways you could do this. It also depends on how you're checking collision, and what kind of data your tiles have. If all solid tiles are just a rectangle bounding box, you'll probably need to flag them as a slope, otherwise you can probably work something out with the gradient of the slope in the collision polygon. Would you mind adding some more details about your current engine and how it does collision and tiles? \$\endgroup\$ – Ben Oct 10 '14 at 4:55
  • 1
    \$\begingroup\$ See also: gamedev.stackexchange.com/questions/8336/… \$\endgroup\$ – Josh Oct 10 '14 at 5:02
  • 1
    \$\begingroup\$ And this: gamedev.stackexchange.com/questions/4059/… \$\endgroup\$ – Josh Oct 10 '14 at 5:03