PowenKo, Unity Tutorials b63-2, 3D model , Animation

January 2, 2012   ·   0 Comments

Screen Shot 2012-01-01 at 11.11.58 PM

using UnityEngine;
using System.Collections;

public class b63_3dmodel_aniCode : MonoBehaviour {
	
	
	
	
	
	// Use this for initialization
	void Start () {
		
		
		animation.wrapMode = WrapMode.Loop;

animation["attack"].wrapMode = WrapMode.Clamp;
animation["charge"].wrapMode = WrapMode.Clamp;
animation["idlebattle"].wrapMode = WrapMode.Clamp;
animation["resist"].wrapMode = WrapMode.Clamp;
animation["victory"].wrapMode = WrapMode.Clamp;
animation["salute"].wrapMode = WrapMode.Clamp;
animation["die"].wrapMode = WrapMode.Clamp;
animation["diehard"].wrapMode = WrapMode.Clamp;
//animation["shoot"].wrapMode = WrapMode.Clamp;
//animation["grab"].wrapMode = WrapMode.Clamp;

animation["idle"].layer = -1;
animation["walk"].layer = -1;
//animation["run"].layer = -1;

animation.Stop();
		
		
	
	}
	 float rotateSpeed=3f;
	void Update ()
	{
		
		transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
		
    if (Input.GetAxis("Vertical")>0.2f || Input.GetAxis("Horizontal")>0.2f) 
    {
        animation.CrossFade("walk");
    }    
    else 
    {
        animation.CrossFade("idle");
    }

		
    if (Input.GetButtonDown ("Jump")){
        animation.CrossFade("attack");
	} 	
    if (Input.GetButtonDown("1")){
        animation.CrossFade("charge");
	}else if(Input.GetButtonDown("2")){
        animation.CrossFade("idlebattle");
	}else if(Input.GetButtonDown("3")){
        animation.CrossFade("resist");
	}else if(Input.GetButtonDown("4")){
        animation.CrossFade("victory");
	}else if(Input.GetButtonDown("5")){
        animation.CrossFade("salute");
	}else if(Input.GetButtonDown("6")){
        animation.CrossFade("die");
	}else if(Input.GetButtonDown("7")){
        animation.CrossFade("diehard");
	} 
	

}
	
	
	

}

reference: http://unity3d.com/support/documentation/ScriptReference/Animation.Play.html

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Unity3D4

Amazon

adsbygoogle

Recent Posts

Categories

Amazon