Is it possible to temporarily resize a sprite for a sliding mechanic?

Hi all,

I’m back again with another issue that has me scratching my head since these forums have been wonderful in helping me with issues in my first month here.

My situation is this - I’ve been using this sample code by SimonDarksideJ as a basis for my own university project, and am trying to add a ‘sliding’ mechanic where the player holds a key down and it makes their hitbox slightly smaller, making it possible to slide under tiles.

The problem I have is that it doesn’t seem possible, at least with my current understanding - I have tried resizing the sliding sprite sheet to be 32x32 where the walking and idling were 64x64, but that just makes the player fall through the floor or float while sliding.

I have also added a boolean so that the game recognizes when the player is sliding which works and shows the sliding frames, but whenever they reach the side of a tile they should be able to slide under they stop and play the idle animation, presumably because the invisible part of the 64x64 sliding sprite sheet is colliding with the top part of the impassable tile.

So my question is, am I missing something obvious? I’m still new to monogame and have no clue if a mechanic like this is even possible, or just impossible with the sample code I’m adapting.

Sample code’s player class

My player class

Additional information:
I’m using the most recent release, NuGet 3.8 on Visual Studio 2019.
The project I set up is “for the Windows desktop using DirectX” and I’m on Windows 10 x64.
I’m testing all this on my laptop, and it’s a computer-only project so the gamepad/touch features in the sample code have been deleted / are not included in my project.

Try reducing the height of the hitbox to the size of the slide region.