Hello!
I simply can't make sense of parallax positioning logic, both in Editor and at runtime.
Help me figure it out with this simple scenario:
Hard requirements (cannot be changed) :
- The root node of the scene must be at (0,0) no matter what.
- It contains a sprite that represents the ground. That sprite is 1000x1000 and its top left is positioned at (0,0) no matter what
For context, the player starts at (500,1000) (i.e. in the bottom middle of the "ground" sprite). In the drawing, I pretend the player is just one 1x1 px (I don't care about his width/height when I talk about his position).
The camera is 200x200 and is attached to the player. Therefore, it's properly positioned when the room starts. That's not part of this question.
How I set the parallax up:
- Add a ParallaxBackground
- Add one ParallaxLayer to it, with a scale of x:0,5 y:0,5
- This ParallaxLayer contains one 100x100 sprite representing the sun
What I want :
- When the scene hasn't started yet (Editor), the sun is directly under the player
- When the scene has started (runtime) the sun starts directly under the player. Then of course it moves laterally when the payer moves, because of the parallax.
EXPLAIN TO ME LIKE I'M MENTALLY DISABLED :
- What calculations does Godot perform to position the parallax? What is the point of origin? Etc.
- Explain de difference (in this context) between **Transform **and **Offset **for the ParallaxLayers
- No matter what I do, I always end up using trial and error for those values. Explain!!!!!!!!!!!!!!!!!!!!!!1111!!!1111!!!!!!!!!! 🙂