I have a image sequence that I want to place on a terrain is that even possible in Unity. I know how to place a animated sequence on geometry with a shader but can I do it this way?
Given you want to swap images on the projectors material, here's how I tried this out. Put it on the projector. Make sure you use the appropriate projector shader.
public class AnimatedProjector : MonoBehaviour
{
public float fps = 30.0f;
public Texture2D[] frames;
private int frameIndex;
private Projector projector;
void Start()
{
projector = GetComponent<Projector>();
NextFrame();
InvokeRepeating("NextFrame", 1 / fps, 1 / fps);
}
void NextFrame()
{
projector.material.SetTexture("_ShadowTex", frames[frameIndex]);
frameIndex = (frameIndex + 1) % frames.Length;
}
}
- As a side note: I had a hard time tweaking my material so it wouldn't look dodgy on the terrain. In case you experience blocky terrain where the projector shoots, try fixing your material shader (projector shader) and make sure your textures are set to clamp.