Thank you for trying to help me.
But the topic you’ve shown me shrinks the object by a keypress. What I wanted to achieve is, for the object to gradually shrink when pressing against the wall and then, for it to gradually return to its the original size when it would no longer collide with the wall.
I was able to code it but it keeps on jittering between sizes.
Hmmm… Is the collission detection necessary? It just seems like the wrong approach to me - but then I don’t know exactly what your usecase is. Could a raycast be used instead? I imagine the raycast would give you pixel-perfect scaling values, and therefore no jittering at all?