using UnityEngine;
using System.Collections;
public class Zombie : MonoBehaviour {
private GameObject player;
public float speed =5f;
public GameObject HUD;
// Use this for initialization
void Start () {
player = GameObject.Find("mainPlayer");
Texture2D[] textures = Resources.LoadAll<Texture2D>("Textures");
Texture2D texture = textures[Random.Range(0, textures.Length)];
HUD.GetComponent<Renderer>().material.mainTexture = texture;
}
// Update is called once per frame
void Update () {
transform.position = Vector3.MoveTowards(transform.position, player.transform.position , speed * Time.deltaTime);
}
}
I have this code for a zombie game and I need to get each zombie that spawns to basically be a different pattern. I have a folder named “textures” and set this code up for it, but it won’t work. The zombies(which are cubes) are still just white. Any suggestions?,