Hey,
I want to make a 2D Sprite animation, buy changing the offset of the material depending on the rotation.
So I made a material with the shader transparent/cutout/diffuse and the texture is a png image which has every step inside to “roll” with offset
There is an empty gameobject without a renderer.
In this empty game object is a 3D text with Mesh renderer and the font material.
in the empty game object there is also a plane with a mesh renderer, which has the material I want to “scroll” with offset.
Here is the script on the empty gameobject (reduced to the problem):
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public Renderer mat1;
public float i;
// Use this for initialization
void Start ()
{
mat1 = transform.FindChild ("playerPlane").renderer;
}
// Update is called once per frame
void Update ()
{
i++;
if(Input.GetKey (KeyCode.W))
{
mat1.material.mainTextureOffset = new Vector2(i,20f);
Debug.Log(mat1.material.GetTextureOffset("_MainTex") + " - " + i);
}
}
}
the print function works correctly, but the image doesnt change,
I see something on the edges like black pixels that appear and dissappear, maybe something is moving, but not the image itself.
Anyone an idea?