- Home /
Question by
D3m0nE · Mar 27, 2013 at 12:42 PM ·
errorgameobjecttexturebullethole
Change Texture of Clone
Hello Everyone
i'm trying to do advanced BulletHole
i use this code [Attached To The Bullethole Prefab] to change Texture :
public string MyType;
public Texture[] Wood;
public Texture CurrentTexture;
public void UpdateMyTexture() {
int random;
if(MyType == "Wood"){
random = Random.Range(0, Wood.Length - 0);
CurrentTexture = Wood[random];
}
transform.Rotate(new Vector3(0,0,Random.Range(-180.0f,180.0f)));
transform.renderer.material.mainTexture = CurrentTexture;
}
and in Shoot System [ Attached To The Player ];
GameObject go;
float delta = -0.02f;
Vector3 hitUpDir = hit.normal;
Vector3 hitPoint = hit.point + hit.normal * delta;
switch(hit.collider.tag)
{
case "Wood":
BulletManager.MyType = "Wood";
go = GameObject.Instantiate(BulletHole, hitPoint, Quaternion.FromToRotation(Vector3.up, hitUpDir)) as GameObject;
break;
the problem i get is : when i shoot and set a new texture for the bullet its change all old BulletHoles not only the new one
Comment
Your answer
Follow this Question
Related Questions
How to make emissive maps glow? 2 Answers
texture import error 0 Answers
GUI Texture error. 1 Answer