moveWithCollisions triggering erratic movement jumps during sprite rotation?

Hi! This is my first post here and my first attempt at game dev (long time boring web/app developer!). I thought Playdate would be a great constrained platform to get started building simple games for my kid.

I'm working on what will become some kind of racing/car game, using the macOS SDK v2.0.3 (simulator-only; hardware coming in the next few weeks!). I'm having an issue with moveWithCollisions. Everything behaves normally but occasionally, as I rotate my sprite, I'll get a weird jump to a faraway position. (See video for an example--the car jumping back is not a video glitch, it's what happens in the game).

collision

I've tried to fix this bug in lots of different ways, but it seems that moveWithCollisions is doing all the move logic itself, and opaque to me. If there were another function like maybeMoveWithCollisions that would let me do the actual move based on whether the actual x and y positions are acceptable to me, then I think I could have a workaround.

But instead I should probably get to the bottom of what's going on. The only 'weird' thing I'm doing is that I'm rotating my sprite, and as I rotate the sprite I'm redrawing the collision rect to attempt to make it match the size/shape of the rotated sprite better. The 'jump' seems to only happen while I'm colliding AND rotating at the same time.

Anyone have any ideas?

I had similar issues with a 2D sidescroller minigame that used the sprite system.

This is what you want, I think: playdate.graphics.sprite:checkCollisions(...).

Good luck! :slight_smile:

Aha! That was it. Thanks for pointing that out. Now I have another problem, which is that my collision rect update function causes the car to collide merely when rotating, which isn't ideal. But this is something I think I can figure out from here. Cheers!

1 Like