Collision for 2D Platformer, when running down a slope.

Hi there,

I’m trying to get my 2D character movement looking good when running up and down slopes.

When the sprite is running up and down a hill, it seems the best way to place it in Y is to use the central point at the bottom of the sprite to position it, as shown below…

image

The problem is this conflicts with the SafeMoveUpdatedComponent() function, which uses a shape sweep with the Box Collider. Which pushes the sprite up…

image

I’m thinking of maybe using the SafeMoveUpdatedComponent() when on a flat surface, to get good quality collision all round. Then when on a slope, using a custom solution to determine Y height and left/right collision against walls. Is this a sensible way to go?

Has anyone else dealt with this?

FYI - I’m using my own movement component derived from UPawnMovementComponent.

Any help would be appreciated…

  • Rich