- Home /
Changing an object from a capsule to a cube.
Hi, I am trying to create a basic character creation scene for my game. I have made one to change the colour of the object, but now I want to try and make one to change the shape of the object. The problem is I am not 100% sure how to go about this. Is there a way to just say for the object to be a cube? Or are there no prefabs for that like there is with colour? Below is the code that I have so far, I omitted most of the stuff to do with the colour changing so it didn't get cluttered. Any help is appreciated.
using UnityEngine; using System.Collections;
public class CharacterCreator : MonoBehaviour {
int colorCounter = 1;
int shapeCounter = 1;
void OnGUI()
{
if (GUI.Button (new Rect (250, 300, 25, 25), "<"))
{
colorCounter --;
print (colorCounter);
}
GUI.Label(new Rect(300,300,50,25), "Color");
if (GUI.Button (new Rect (350, 300, 25, 25), ">"))
{
colorCounter ++;
print (colorCounter);
}
if (GUI.Button (new Rect (250, 300, 25, 25), "<"))
{
shapeCounter --;
print (shapeCounter);
}
GUI.Label(new Rect(300,300,50,25), "Shape");
if (GUI.Button (new Rect (350, 300, 25, 25), ">"))
{
shapeCounter ++;
print (shapeCounter);
}
}
void Awake()
{
print (colorCounter);
print (shapeCounter);
}
void Update()
{
Component meshFilter = GameObject.FindGameObjectWithTag ("Player").GetComponent<MeshFilter>().mesh;
switch (shapeCounter)
{
case 0:
shapeCounter = 3;
break;
case 1:
meshFilter =
break;
case 2:
shapeCounter = 2;
break;
case 3:
shapeCounter = 3;
break;
case 4:
shapeCounter = 1;
break;
}
}
}
Thanks, Brendan.
Answer by mattehunter1 · May 26, 2014 at 04:51 PM
Delete the capsule and make a cube, i dont think just transferring is possible
Yeah I wasn't 100% if you could. Thanks for the response though. I'll leave the question open in case someone has a more definitive answer.
Your answer
![](https://koobas.hobune.stream/wayback/20220613145917im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Changing a Mesh (C#) 1 Answer