Setting up the background scroll schematic.
In this short, final tutorial, we’ll make the background scroll to create a better visual effect for moving through space.
The schematic will use local start variables that define the start position, scroll speed and size of the background. We’ll need them for the scrolling mechanic.
Open the Makinom editor, navigate to Schematics and create a new schematic. Change the following settings.
We’ll set up local variables as Machine Start Variables for easy setup in the machine component at a later time. When using the schematic in a machine component, the defined start variables will be added automatically, using their default values.
Click on Add Start Variable to add a local start variable that will be exposed to the machine component’s inspector.
Again, click on Add Start Variable to add another local start variable.
Copy the previous start variable and change the following settings.
Add Node > Value > Variable > Change Variables
We’ll do a first calculation for the new scroll positition by multiplying the scroll speed with the current time.
Click on Add Variable to add a variable change.
Copy the variable change and change the following settings.
Add Node > Value > Float > Float Ping Pong
This node will ping pong or loop a float value between two defined values and store it into a variable. We’ll use it to loop the scroll position according to the tile size.
Now, we’ll store the new position the background object will be set to into a Vector3 variable.
Add Node > Movement > Movement > Change Position
Finally, we’ll place the background object at the new position.
And that’s it for the schematic – click on Save Schematic and save it as BGScroll in Assets/Schematics/.
All that’s left to do is adding the schematic to the Background game object in the scene. We’ll use a tick machine component to adjust the position each frame.
Add the component (e.g. using the component menu: Makinom > Machines > Tick Machine) and change the following settings.
The Machine Start Variables we’ve set up in the schematic are automatically added here with their default values – since the default values are already what we need, we don’t have more to do here. Make sure all variables are enabled.
And that’s it – don’t forget to save the scene.
Click on Play to test the game. You’ll now notice the background scrolling at a slow speed.
This concludes the space shooter game tutorial series for now. You can add additional content to the game, e.g. different levels, more enemies or power ups (like increasing the player’s health or decreasing the fire rate).
© 2015 Gaming is Love e.U.
Disclosure: This site may contain affiliate links, which means I may receive a commission if you click a link and purchase something that I have recommended. While clicking these links won’t cost you any money, they will help me fund my development projects while recommending great assets!