Hi, I want to know how to replace the player’s character mesh with another one while playing the game. like that alien transformations from Ben10 Cosmic destruction game., how do I call a model to the scene which was not in the scene before?
![]()
You can instaniate the new modeland destroy the old model. Thats what some do depending on the game. Also ther is a mesh class for all kinds of needs. Then there is the method i just used in a game where all the characers and character items are there the whole time but not active. I make a gameObjects array and use a interger to compare the condition for swapping what is active and what is not active.
Instead of cycling throug the array i cycle through different arrays then load each array with the character parts.
var char0A : GameObject[];
var char1A : GameObject[];
var char2A : GameObject[];
var swapNum : int;
function Update() {
if(Input.GetKeyDown("m")) {
swapNum ++;
}
if((swapNum >= -0)(swapNum <= 0)) {
for( var c in char0A) { c.gameObject.active = true; }
for( var c in char1A) { c.gameObject.active = false; }
for( var c in char2A) { c.gameObject.active = false; }
}
else if((swapNum >= 0)(swapNum <= 1)) {
for( var c in char0A) { c.gameObject.active = false; }
for( var c in char1A) { c.gameObject.active = true; }
for( var c in char2A) { c.gameObject.active = false; }
}
else if((swapNum >= 1)(swapNum <= 2)) {
for( var c in char0A) { c.gameObject.active = false; }
for( var c in char1A) { c.gameObject.active = false; }
for( var c in char2A) { c.gameObject.active = true; }
}
if((swapNum >= 3)(swapNum <=5)) {
swapNum = 0;
}
}
I know this is real shady code but it works pretty good. Once you get the structure down you can add on to it with no problem. The game i used this on gave you many options to pick components for a star vehicle almost 50 sets. and what i did was use player prefs to jus save the swap num and then i could reload the same character/ship as before.![]()
got it!.. ![]()
thanks!