Enabling and Disabling Follow Screen
-
I have a scene that implements parallax backgrounds based on a timer and screen position, works nice and smooth. I have two walls to stop the user at each end of the world (the world is wider than the screen). While playing, the backgrounds show off the end of the world i.e. past the wall.
I have been wrestling with trying to figure out a way to stop the player at the edge of the screen without the extra backgrounds showing.
I have been playing with screen and player positions and I am really close. If I try toggling the players follow screen behavior I can get what I want when hitting the wall without the extra background showing. The white edge is the wall.
When I try to re-enable the follow screen behavior, the whole screen shifts… why it doesn’t hold the same screen position is baffling me. The following is what I get when I detect moving away from the wall and re-enabling the follow screen behavior.
What I want is while not hitting the walls is for the screen to follow the player, this works. When getting to a wall, behave like conform to screen. I can’t use conform to screen as it jacks up the view while the player is jumping. Maybe I am being dull, help!
-
@krdavis The Screen Follow behaviour will follow the player based on where the player is when the behaviour starts working, I think. It’s also possible the the Screen Follow behaviour is acting strangely when disabled then re-enabled. If you want more proper control over the screen, you could try running a timer with 1÷60, that is ~0.0166666667s, not 0, and using either Screen To Object (on an anchor if you don’t want player in dead centre) or Screen To Point if you want to give the screen exact coordinates based on player coordinates.
-
@Aidan_Fire thanks for the timer pointer; however, I am still getting the screen jump when I re-enable follow screen. My screen to point is smooth and accurate. Looks like an issue with the screen follow behavior.
-
@krdavis Odd, when I just tested out disabling and re-enabling a screen follow behaviour in a test project it behaved exactly as I would expect it to. Maybe it depends on the way you’re using it?
-
@Aidan_Fire my player object is moving when I make the change to enable the follow behavior. The trigger to enable is based on a calculation of the player’s position when timer fires at the interval you suggested. Can I see your test project?
Simple question: how do I, with screen follow on, get the player to the edge of the screen and stop…
This hiccup has been driving me nuts!
-
@krdavis Here’s an example project that I think looks like what you might be trying to do. Of course, the nearly transparent large objects should be invisible but I left them visible so you can see them in the test. I hope this helps, all behaviours are in the red square. Screen follow test.tap
-
@Aidan_Fire thanks so much, it was a big help! I found the source of my frustration, I had set the wrong anchor on my player and that was causing the screen jumping.