If (Temp > _startingPos + (_lengthOfSprite / 2))Įlse if (Temp < _startingPos - (_lengthOfSprite / 2)) if (Temp > _startingPos + (_lengthOfSprite / 2)) By including the following piece of code in the Update() function of the Paralla圎ffect.cs script, we can achieve this. To regenerate whether the camera was moved outside of its permitted range, we must determine how far we actually moved the camera and set criteria to do so. Therefore, we must repeat the background for a never-ending effect. The scene without repeating background Making the Background RepeatĪlthough we successfully created a parallax effect, the backgrounds no longer display once we step outside the defined boundaries. If everything has gone according to plan to this point, you should be able to see the parallax effect on clicking the run game button in Unity. For the remaining layers, we must then gradually raise these numbers until they reach 1. We must add 0 to the layer that is in front so that it moves as the camera passes it. 0.5 for the range of the small mountains.
0 Comments
Leave a Reply. |