I spent today setting up my project in Unity. I want to create a parallax effect on my environment and also want some elements in the scene to be interact-able. Because of this, I started out by separating up my sketch into multiple objects. I then imported them and changed their "texture type" to "sprites".To create the parallax I separated my assets up on the sprite editor. I used the automatic slice to separate them into four different objects. I also set the sprite mode to multiple rather than single as there are multiple sprites on this png.
This is what the scene looked like built up in different layers on the game view. I changed the camera from perspective to orthographic and changed the "far" clipping from from 1000 to 10 to save memory. This is because with a 2D side-scroller you don't need that much distance between the camera and the layers.
Adding the assets to sorting layers and then locking them allows you to keep the assets in the order you want.
Using the tutorial suggested to me by Karl Inglott I created this code to try and parallax my background.When the parallaxing script is applied to the background layer, the game does nothing when played in the "game panel".
When it is applied to all the asset layers, the following happens.....
___________________________________________________________________________________________________
(This problem, I think, initially, is because the parallax is not tied to the mouse movement like I'd like it to be. Also, I'm wondering if there needs to be an area the camera is fixed to so when the parallax moves it doesn't zoom straight off the background layer. This happens if the code is applied to the main camera.)


0 comments:
Post a Comment