Scrolling in Unity Space Shooter.

In the last post I was saying that the tutorial of Unity doesn’t describe how to do the scrolling in the SpaceShooter.

To do that, create a script for the Background component, file it under the “Scripts” folder.
And in it write or copy that:

using UnityEngine;
using System.Collections;

public class Scrolling : MonoBehaviour {

public float ScrollingSpeed = 0;

// Update is called once per frame
void Update () {
renderer.material.mainTextureOffset = new Vector2 (0f, Time.time * ScrollingSpeed);

Then save and go back to Unity. Click on the Background component, put a ScrollingSpeed (0.1 is good) and make sure your Texture’s Wrap Mode is in “repeat mode” by selecting the Texture in your Project view.

That’s all, you should now have your scrolling.





Tags: ,

Trackbacks / Pingbacks

  1. Space Shooter 2 | Debugging World - March 15, 2014

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: