I have this big room that's 2 times the size of the viewport, I want the viewport to follow the player, but not show outside the room (so if the player kept moving up the viewport would stop at the wall). Any idea how to do this?
If there is only one room on the level, you can resize layout to room size and disable unbounded scrolling.
If your character can travel from room to room, check out this demo:
dropbox.com/s/ityy4s958d14x7k/PlatformScrollZones.c3p
https://www.dropbox.com/s/8qghjuzcooq1y8c/PlatformScrollZones.c3p?dl=0
I tried to make a camera sprite free version, ignoring the first part about if the room is shorter, do you know where the failure was?
Develop games in your browser. Powerful, performant & highly capable.
Here is a slightly better version:
dropbox.com/s/db0uk7hy8qb2iwo/PlatformScrollZones_new.c3p
You can add lerp(scrollx, clamp(....), 0.1) to make it smoother.
I still prefer to do it with a Camera sprite and MoveTo behavior, because you can configure nice acceleration and deceleration effects.
Thanks dop! Wasn't working at first in my project but it turned out I just named a layer wrong xD
All is sorted now though, thanks alot!
how should i go about doing that clamp? The target position is 3616. Sorry i cant figure this out for the life of me.