To think that after all the time i had coded in danmakufu i didn't know such a simple thing... It makes more sense now, thanks!
But I'm still not so used to using the z-axis, nor do i know everything about it.
Z-axis is used to put things closer or futher away from you. As you know, there are 2 methods of stage scrolling:
- Texture scrolling (just like in 2D drawing, scrolling the graphicrect)
- Moving 3Dobjects and resetting them each time.
It is kind of tricky to explain, perhaps a picture again:
[attach=1]
Here is what you do (this will show you why fuctions are going to be your friend for the rest of your 3D-stage making life):- You create a variable called 'scroll' or w/e (let scroll = 0;)
- Place your floors exactly as they show up in the picture so Floor 1 = createFloor(0,0,0); Floor 2 = createFloor(0,0,-1024); Floor 3 = createFloor(0,0,-2048); (make sure you angle them proper so the Y-side is the longer length.
add the variable scroll to all Z parameters so it becomes:
- Place your floors exactly as they show up in the picture so Floor 1 = createFloor(0,0,0+
scroll); Floor 2 = createFloor(0,0,-1024+
scroll); Floor 3 = createFloor(0,0,-2048+
scroll);
Now add at the end of your background loop or w/e scroll+=4; (or at the speed you wish to scroll) and if(scroll>2048) { scroll = 0; }
So what will happen now? All the floor pieces will start moving
closer to you. Because a
negative value means the floor is away from you and is being moved towards you (by the scroll value). However, once the scroll variable hits 2048,
all the floors will be re-setted back to their original location (because scroll = 0).
Now this will look very stupid if you leave it like this, but if you hide the last floor piece with a dense fog, the player won't even notice the floors being reset because the eyes will be fooled as if the floor pieces keep on coming. Logically, this requires repeating textures for all floors or plain texture, else it will be noticeable. And this is why the most creative builders will fool you with the SetFog.
Just to be warned, you won't probably get it the first time. I didn't either. Takes a lot of trial and error.
- Don't rush it
- Don't try to move EVERYTHING in one go.
- Do it step by step. Create the floors, move them. Use fog to hide the "resetting". Then carry on with the bookshelves.