New CollisionResponse kCollisionTypeUndo

I'm making a game where the character can be moved in a grid, or continuously per a player setting. I would love to be able to handle both types of movement similarly, so a new type of collision response would be very helpful. Basically I would like kCollisionTypeUndo, which says "try to move to the goal point, and if a collision occurs do not move. If such a collisionresponse existed, I could still use moveWithCollisions to handle the grid movement, since some things in the grid will still be moving continuously around the player.

Hi Zac,

Would you be able to use for this? It does the same thing as :moveWithCollisions() without actually moving the sprite. If no collisions are detected you could then just call :moveTo() to move the sprite to the un-collided location.

That's what I ended up using, but the resulting code is quite a lot messier than the alternative would be. This request isn't so much "I can't do the thing I want to" as much as it is "doing the thing I want to requires me to sacrifice a lot of legibility", especially given that the rest of the changes required to switch settings are just changes to how the sprite and some constants are set up.

You could wrap up your desired functionality in a new method, maybe something like:

function, y)
	local _, _, _, collisionCount = self:checkCollisions(x, y)
	if collisionCount == 0 then
		self:moveTo(x, y)

Without seeing more code it's hard to say why this solution would be leading to legibility problems, but that might be something the community here can help with! :slight_smile: