The Message “Better way to set up “padding”” makes lot of sense, and can vary with your sprite size, which I think is great. My first thought upon completing the lesson, though, was that if we’re using Camera.ViewportToWorldPoint so we could clamp the limits in world space, shouldn’t we define padding in world space values, as well, not screen space values?
That seems like a sensible suggestion. That way everything would be consistent that way. I guess if you wanted the visual padding space to be constant no mater what scale the game had you might want the other way.
hey i want to use this code however i cant find a answer on the internet as to a further explanation behind
extents.
i get bounds is the box that encloses the object, however i don’t get extents and what it means by always half of the size?
thanks in advance.
I did it this way.
Get the SpriteRenderer
From this, get the bounds of the player sprite.
Add the x bounds to minX, subtract from maxX and the sprite goes to the edge.
It may be you want to add a small amount of additional padding (probably 0.05f would do)
I actually stopped the video before he got to the padding value because I didn’t like the sprite going off the screen. I came up with a solution that is dependent on pixels per unit of your sprite, but will scale if you import a different sprite.