Makinom - Game Toolkit for Unity
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom

Guide

Schematics

  • Setting the Player
  • Simple Character Controller
  • Mouse Orbit Camera
  • Random Waypoints

Breakout

  • Breakout Tutorial Introduction
  • 01 First Steps
  • 02 Player Controls
  • 03 Bricks
  • 04 Losing a Life
  • 05 UI Setup
  • 06 Sound Assignments

Space Shooter

  • Space Shooter Tutorial Introduction
  • 01 First Steps
  • 02 Player Move Controls
  • 03 Player Weapon Controls
  • 04 Hit and Destroy
  • 05 Asteroids
  • 06 Game Controller
  • 07 UI Setup
  • 08 Player’s Destruction
  • 09 Enemy Ship Mechanics
  • 10 Enemy Ship
  • 11 Moving the Background

Match 3

  • Match 3 Tutorial Introduction
  • 01 First Steps
  • 02 UI Setup
  • 03 Generating the Level
  • 04 Matching Jewels
  • 05 Destroying Jewels
  • 06 Game Controls
  • 07 Jewel Setup

Survival Shooter

  • Survival Shooter Tutorial Introduction
  • 01 First Steps
  • 02 Player Movement
  • 03 Player Shooting
  • 04 Enemy Mechanics
  • 05 Setting up the Enemies
  • 06 UI Setup
  • 07 Player’s Death
  • 08 Enemy Spawner

2D Roguelike

  • 2D Roguelike Tutorial Introduction
  • 01 First Steps
  • 02 Generating the Level
  • 03 Level Generation Machines
  • 04 Player Controls
  • 05 Walls, Food and Exit
  • 06 Game Manager and UI Setup
  • 07 Enemy Mechanics
  • 08 Game Over

2D Platformer

  • 2D Platformer Tutorial Introduction
  • 01 First Steps
  • 02 Player Movement
  • 03 Camera and Background
  • 04 Shooting Rockets
  • 05 Enemy Mechanics
  • 06 Setting up the Enemies
  • 07 Enemy Spawners
  • 08 Player Damage and Fall Remover
  • 09 Health Pickup
  • 10 Bomb Pickup
  • 11 Bomb Prefabs and Lay Bombs
  • 12 Pickup Spawner
  • 13 UI Setup
  • 14 Background Animations
  • Home
  • Guide
  • Tutorials
  • Space Shooter
  • 11 Moving the Background

11 Moving the Background

Table of Contents
  • BG Scroll: Schematic
    • Settings
      • Machine Start Variables
    • Change Variables
    • Float Ping Pong
      • Variable Settings
      • Value
      • Length
    • Change Variables
    • Change Position
      • Moving Object
      • Target Position
  • BG Scroll: Tick Machine
    • Start Settings
    • Machine Execution Settings
    • Local Start Variables
  • Testing

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.

BG Scroll: Schematic #

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.

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.

Machine Start Variables #

Click on Add Start Variable to add a local start variable that will be exposed to the machine component’s inspector.

  • Variable Key
    Set to startPosition.
  • Type
    Select Vector3.
  • Default Value
    Set to X=0, Y=-10, Z=0.

Again, click on Add Start Variable to add another local start variable.

  • Variable Key
    Set to scrollSpeed.
  • Type
    Select Float.
  • Default Value
    Set to -0.25.

Copy the previous start variable and change the following settings.

  • Variable Key
    Set to tileSizeZ.
  • Default Value
    Set to 30.

Change Variables #

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.

  • Change Type
    Select Variable.
  • Variable Key
    Select scrollPosition.
  • Variable Origin
    Select Local.
  • Type
    Select Float.
  • Operator
    Select Set.
  • Float Value
    Select Variable > Float Variable.
  • Variable Key
    Set to scrollSpeed.
  • Variable Origin
    Select Local.

Copy the variable change and change the following settings.

  • Operator
    Select Multiply.
  • Float Value
    Select Time > Time.

Float Ping Pong #

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.

  • Use Repeat
    Enable this setting.
    We want to loop instead of ping pong the value.

Variable Settings #

  • Variable Key
    Set to scrollPosition.
  • Variable Origin
    Select Local.
  • Operator
    Select Set.

Value #

  • Value
    Select Variable > Float Variable.
  • Variable Key
    Set to scrollPosition.
  • Variable Origin
    Select Local.

Length #

  • Value
    Select Variable > Float Variable.
  • Variable Key
    Set to tileSizeZ.
  • Variable Origin
    Select Local.

Change Variables #

Add Node > Value > Variable > Change Variables

Now, we’ll store the new position the background object will be set to into a Vector3 variable.

Click on Add Variable to add a variable change.

  • Change Type
    Select Variable.
  • Variable Key
    Select newPosition.
  • Variable Origin
    Select Local.
  • Type
    Select Vector3.
  • Operator
    Select Set.
  • Float Value
    Select Vector3 Variable.
  • Variable Key
    Set to startPosition.
  • Variable Origin
    Select Local.

Copy the variable change and change the following settings.

  • Type
    Select Axis Vector3.
  • Axis
    Select Z.
  • Operator
    Select Add.
  • Float Value
    Select Variable > Float Variable.
  • Variable Key
    Set to scrollPosition.
  • Variable Origin
    Select Local.

Change Position #

Add Node > Movement > Movement > Change Position

Finally, we’ll place the background object at the new position.

Moving Object #

  • Object
    Select Machine Object.
  • Movement Component
    Select Transform.

Target Position #

  • To Object
    Disable this setting.
  • Vector3 Type
    Select Vector3 Variable.
  • Variable Key
    Set to newPosition.
  • Variable Origin
    Select Local.

And that’s it for the schematic – click on Save Schematic and save it as BGScroll in Assets/Schematics/.

BG Scroll: Tick Machine #

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.

Start Settings #

  • Update
    Enable this setting.

Machine Execution Settings #

  • Schematic Asset
    Select BGScroll.
  • Execution Type
    Select Single.
  • Update Type
    Select Update.

Local Start Variables #

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.

Testing #

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).

Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on December 17, 2020
Table of Contents
  • BG Scroll: Schematic
    • Settings
      • Machine Start Variables
    • Change Variables
    • Float Ping Pong
      • Variable Settings
      • Value
      • Length
    • Change Variables
    • Change Position
      • Moving Object
      • Target Position
  • BG Scroll: Tick Machine
    • Start Settings
    • Machine Execution Settings
    • Local Start Variables
  • Testing
Sitemap
  • Features
  • Showcase
  • Guide
    • Documentation
    • Tutorials
    • Extensions
    • API
  • Makinom 1 Hub
    • Tutorials
    • Plugins
    • API
  • Support
  • Forum
  • Get Makinom
  • Contact
  • Blog
  • ORK Framework
  • gamingislove.com
Categories
  • Makinom 1 (97)
    • Tutorial (97)
      • 2D Platformer (14)
      • 2D Roguelike (8)
      • Breakout (6)
      • How-to (34)
      • Match 3 (6)
      • Schematic (4)
      • Scripting (6)
      • Space Shooter (11)
      • Survival Shooter (8)
  • News (11)
  • Release (68)
Search

© 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!