Character Changing forms

Okay, I'm fairly noobish when it comes to scripting. But I'm trudging forward anyway, and could use a fair amount of help with what I assume is a simple issue.

the character from my game is able to shift his form from one thing to another. Now, I need a script that will, at the touch of a button, change him into his new form.

So, if someone could point me in the right direction it would be greatly appreciated. To summarize, the script needs to do the following after pressing one button:

-Stop the control of the character. -Play an animation of him transforming. -At the end of the the animation, swap out Character Model A with Character Model B at the exact same position. -Apply a different control script to the newly transformed Model B. -Re-enable controls.

Now, this sounds like a lot, but I think it's fairly simple. So if anyone could help out, it'd be greatly appreciated. Thanks in advance!

I don't really have time to write a script for you that would do this, but I will gladly stub something out that will hopefully push you in the right direction:

Boolean _canControl = true;
AnimationClip _transformClip;

//use for initialization purposes
function Awake():void
    //this is where you apply animation events

    //you want to set up an animation event that calls the function TransformationComplete() when the animation finishes
    ae = new AnimationEvent();
    ae.time = _transformClip.length; //the time in which it takes to complete
    ae.functionName = "TransformationComplete"; //we will call the function named this when the animation completes

//called when our transformation animation completes
private function TransformationComplete():void
    //here we swap the model, please refer to the post on UnityAnswers to figure out how to do this

    //restore controls
    _canControl = true;

public function TransformCharacter():void
    //strip controls
    _canControl = false;

    //tell the animation to play
    animation.clip = _transformClip;
    animation.Play();//note, this won't blend the animations together, to use that you'll want to use animation.CrossFade()

//where your controls are implemented.

function FixedUpdate():void
    if(!_canControl) return; //early out if the user cannot control

My apologies, I typically use C# but you mentioned you aren't much for coding, so I used JS to make it easier. My JS is a little rusty so there are probably mistakes in my syntax...

I hope that helps you out,


I also don't have time to implement this for you - but I can point you to a question that I think has the answer you are looking for (even though it also doesn't offer an implementation - but at least the concept you'd need for the implementation):