How to transform a object to another when a object of tag “Hitter” hit it?
Any comment and solution is appreciated here!
Depends on what you mean by transform I am assuming that you mean change the current model of the object? If so then you need to disable the model you are currently using and instantiate a new one. Something to the effect of:
currentModel.SetActiveRecursively(false);
newMode.SetActiveRecursively(true);
Pretty sure you could also do something like:
GameObject meshA;
GameObject meshB;
OnColliderEnter()
{
player.SetActive(false);
MeshFilter meshFilter = player.GetComponent<MeshFilter>();
meshFilter.mesh = meshB.GetComponent<MeshFilter>().mesh;
player.SetActive(true);
}
Or have all the models you want as children of the main object then use:
currentModel.SetActive(false);
newModel = player.transform.Find("ModelB").gameObject;
newModel.SetActive(true);
currentModel = newModel;