Switching Character States With SetActive.... need some help

Hi,

I’ve written a script that switches my character from her normal state to her Ball form. They are completely different game objects with different physics and movement controls. Otherwise, I would have used renderer.enabled. I was able to get the two objects two switch by making them children of a parent object (which I’ve called “MainCharacter” in the script) and attaching the following script to the parent. The problem is that once an object becomes active, it starts at the place it was last active instead of the place where the object before it was active, and it retains its last active velocity properties. So what I’d like is when the switch happens, the newly active object inherits the velocity and transform of the previously active object. Hope that all makes sense! Here is the code in c#

using UnityEngine;
using System.Collections;

public class SwitchStates : MonoBehaviour {

public Transform MainCharacter;
public GameObject MC;
public GameObject Ball;
public bool ball;
public bool normal;

void Start()
{

	Ball.SetActive (false);
	MC.SetActive(true);
}

void Update () 
{
	if (MC.activeSelf)
		normal = true;
	else
		normal = false;
	if (Ball.activeSelf)
		ball = true;
	else
		ball = false;

if (Input.GetButtonDown ("Fire2") && normal)
	{
		Ball.transform.position = MainCharacter.position; 
		MC.SetActive(false);
		Ball.SetActive(true);
	}
if (Input.GetButtonDown ("Fire2") && ball) 
	{
		MC.transform.position = MainCharacter.position;
		Ball.SetActive(false);
		MC.SetActive(true);
	}
}

}

thanks!!

Instead of just setting it to active, create a function to set a number of the properties for the object. Something like this:

void Update()
        {

            if (MC.activeSelf)
                normal = true;
            else
                normal = false;

            if (Ball.activeSelf)
                ball = true;
            else
                ball = false;

            if (Input.GetButtonDown("Fire2") && normal)
            {
                ActivateBall();
            }
            if (Input.GetButtonDown("Fire2") && ball)
            {
                ActivateNormal();
            }
        }

        void ActivateBall()
        {
            Vector3 mcVelocity = MC.GetComponent<Rigidbody>().velocity;
            Vector3 mcPosition = MC.transform.localPosition;
            MC.SetActive(false);
            Ball.SetActive(true);
            Ball.GetComponent<Rigidbody>().velocity = mcVelocity;
            Ball.transform.localPosition = mcPosition;
        }

        void ActivateNormal()
        {
            Vector3 ballVelocity = Ball.GetComponent<Rigidbody>().velocity;
            Vector3 ballPosition = Ball.transform.localPosition;
            Ball.SetActive(false);
            MC.SetActive(true);
            MC.GetComponent<Rigidbody>().velocity = ballVelocity;
            MC.transform.localPosition = ballPosition;
        }