- Home /
How Can we make moving background like in Magnets game ??
Hello everybody, i am trying to make moving background meanwhile changing color like in the game Magnets but i have no idea how to make it. Any ideas ??

can you be more specific? include a video or a gif? I can't really figure out what you want to do from a still picture
Answer by Graphics_Dev · Mar 02, 2016 at 07:23 PM
You need a UV scroller:
using UnityEngine;
using System.Collections;
public class UVScroll : MonoBehaviour
{
public float offsetX = 0.5F;
public float offsetY = 0.5F;
private Renderer rend;
void Start()
{
rend = GetComponent<Renderer>();
}
void Update()
{
float offsetx = Time.time * offsetX;
float offsety = Time.time * offsetY;
rend.material.mainTextureOffset = new Vector2(offsetx, offsety);
}
}
Let me know if this helps ;)
Scipt is working good. But how can we change the color ? What kind of shader should we create?
Once again please leave as a comment just click add comment below answer or question you are responding to ;)
I would suggest asking a new question like "How can I change material color smoothly with C#?"
Try to keep each question to just one =)
Please mark my answer as correct to close this question.
Sure. I will creaete the next question and would apreciate if you help me )
Answer by phil_me_up · Mar 02, 2016 at 06:51 PM
Not totally sure what you're asking for, but shaders are probably what you're after. Using shaders you can scroll texture UV, change colouring etc.
They can be a bit confusing for beginners but if you want to make pretty games, they are essential.
Video of $$anonymous$$AGNETS GA$$anonymous$$E
Please take a look at this video . You can see how background changes the color and cubes are moving.
Yep, see my Shaders answer. That's the way to go on this.
Can you please show me an example ? video or link with info about it ?
It really doesn't have much to do with shaders. Its like 3 lines of C# that adjust the material offset property.
Your answer