Character Change Within Level

I’m sure you guys know of this in games, where a player’s character is in a beat streak fighting enemies and then is able to enter a rage mode or something.

What I need to figure out is this: I have a character that I want to change form when the meter is full. The concept would be changing one character prefab into another and have the meter on a time based decrease. When the meter is empty I want the player to revert back to the first form. The two character prefabs have a separate armature, build, and animations. I want to avoid parenting the second character prefab to the first one because I had issues with the character controller doing that.

How would I go about doing this?

Hi,

how about having both characters instantiated in the scene and set them to active/inactive as you need. gameObject.setActive(). Of course, both character prefabs would have to be able to react to user input. Another way I can think of is to have an InputManager and you call certain actions on either your first or second character, based on which one is active. You do not have to deactivate a character gameobject. maybe it is enough to move them out of the cameraview.

Another possibility is to have them controlled both at the same time (both have the same root transform, so the always are in the same place) but render only one of them. Collisions against other characters should only be performed with the visible character.

This is what I was able to come up with and it works fine:

public Rigidbody nextForm;
Rigidbody instantiatedNextForm;
public GameObject tempTeleport;
public Transform player;

I have a separate game object away from the level platform out of view from the player and named/tagged it tempTeleport

 void SetTeleport() {
    		tempTeleport = GameObject.FindWithTag ("tempTeleport");
    }

I have the instantiated second prefab spawn in to the first prefab’s position and rotation after the meter is filled. Then right after I had the first prefab change it’s transform to the tempTeleport game object’s position with the controls disabled.

 instantiatedNextForm = Instantiate (nextForm, player.position, player.rotation) as Rigidbody;
    Vector3 playerPosition = (player.position = tempTeleport.transform.position);
    
    GameObject.Find ("Form1");
    if (GameObject.Find ("Form1") != null) {
            GameObject.Find ("Form1").GetComponent<CharacterControlForm1> ().enabled = false;
    }

There’s a separate camera parented to the second prefab so I didn’t have to worry about the view messing up. Any newly added camera’s in the game scene just overlap each other.

The meter then decreases and the second prefab has it’s controls. When it runs out, the first player prefab’s transform goes right back to the second one, I have the second prefab destroyed, and enable the first prefab’s controls, and start it all over again when the meter is filled.

Vector3 playerPosition = (player.transform.position = instantiatedNextForm.transform.position);
Destroy (instantiatedNextForm.gameObject);

GameObject.Find ("Form1");
if (GameObject.Find ("Form1") != null) {
        GameObject.Find ("Form1").GetComponent<CharacterControlForm1> ().enabled = true;
}

I dislike answering my own questions, but I’m self taught with programming. I will eventually solve it… Thank you all who put in their answers. It’s very much appreciated! :slight_smile: