How to make a sprite coming towards us from far away in 2D ?
As an example, if we get the black box sprite I just wanted to make it move towards us by changing Z Position. But it doesn't work as it doesn't make any change if I change Z Position value.
Can you help me to do this ??
I want to initialize these type of 2D sprites randomly and make it move towards us like in a space travel scene
Answer by kalen_08 · Jul 18, 2018 at 03:53 PM
You need to change your camera to perspective. It will still work for your 2d Sprite but the effect you are looking for will then be visible. You could just have an orthographic camera in this scene or for your entire game. It will give it a different feel. You see for yourself. You could also do like the other guy said in changing the scale but the object isn't getting bigger insults getting closer. So i think this will be more of want.
Let me know.. :)
You can just adjust the clipping on the camera and spawn the objects past that. (Then they won't be just appearing)
And then have a variable on them, speed, controlling how fast they move past you. Then also have them destroy themselves once they're beyond a certain negative z value when you can no longer see them (wouldn't want so many useless gameobjects in play)
Answer by BartiriX · Jul 18, 2018 at 03:18 PM
Hi there! Depth doesnt work in 2D because you work with what is called an ortographic view. Moving along rhe Z-axis can be very useful for sorting background and foreground objects, but in order to make things smaller you’ll habe to rescale the X and Y axis equally.
Tl;dr: Use X and Y scale.