- Home /
 
How to transform a object to another when a object of tag "Hitter" hit it?
How to transform a object to another when a object of tag "Hitter" hit it? Any comment and solution is appreciated here!
Transform.SetParent comes to $$anonymous$$d. Be more specific - how are you checking collisions, what code have you written, what's not working
So do you mean that the object changes to another object when hit?
No, I misread what you meant and focused on "transform" in the literal sense for Unity; disregard.
Answer by mythirdalias · Jan 15, 2018 at 12:29 PM
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);
 
               https://answers.unity.com/questions/55196/changing-player-model-with-keypress.html
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;
 
              Your answer
 
             Follow this Question
Related Questions
How can I modify this rotation code to change how far the object rotates? 0 Answers
Move Object to location of Trigger? 1 Answer
Object movement / rotation error 0 Answers
Adding data to a set of transforms 1 Answer
Problems with IK implementation 0 Answers