6 Анимация стрельбы и перезарядки


В скрипт стрельбы, функция update:

	if(Input.GetKeyDown(KeyCode.R))
	{
		hd.svumode = 4;
	}

Анимация рук персонажа:

using UnityEngine;	 
	using System.Collections;	 
	public class Hands2 : MonoBehaviour {	 
	 /*	 
	 * 0-idle	 
	 * 1-takeSVU	 
	 * 2-takeSVU2	 
	 * 3-svuidle	 
	 * */	 
	 public Transform SVU;	 
	 public int mode;	 
	 public int svumode;	 
	 private float svutake1;	 
	 private float svutake2;	 
	 private float svustartrun;	 
	 private float svuendrun;	 
	 private float svureload;	 
	 void Start()	 
	 {	 
	 animation["svutake1"].speed =2;	 
	 animation["svutake2"].speed =2.5f;	 
	 animation["svuendrun"].speed = 1.8f;	 
	 animation["svurun"].speed = 2;	 
	 }	 
	 // Update is called once per frame	 
	 void Update () 	 
	 {	 
	 //Hands	 
	 if(mode==0)	 
	 {	 
	 animation.Play("idle", PlayMode.StopAll);	 
	 }	 
	 if(Input.GetKeyDown(KeyCode.E))	 
	 {	 
	 animation.Play("svutake1", PlayMode.StopAll);	 
	 mode=1;	 
	 }	 
	 if(mode==1)	 
	 {	 
	 svutake1 += Time.deltaTime;	 
	 }	 
	 if(svutake1>=animation["svutake1"].length/2)	 
	 {	 
	 SVU.GetComponent<MeshRenderer>().enabled = true;	 
	 SVU.GetComponent<RaycastShooting2>().enabled = true;	 
	 animation.Play("svutake2", PlayMode.StopAll);	 
	 svutake1 = 0;	 
	 mode=2;	 
	 }	 
	 if(mode==2)	 
	 {	 
	 svutake2 += Time.deltaTime; 	 
	 }	 
	 if(svutake2>=animation["svutake2"].length/2.5f)	 
	 {	 
	 mode=3;	 
	 }	 	 	 
	 //SVU	 
	 if(mode==3)	 
	 {	 
	 if(svumode==0)	 
	 {	 
	 animation.CrossFade("svuidle");	 
	 if(Input.GetButton("Vertical"))	 
	 {	 
	 animation.CrossFade("svustartrun");	 
	 svumode=1;	 
	 }	 
	 }	 
	 if(svumode==1)	 
	 {	 
	 svustartrun += Time.deltaTime;	 
	 }	 
	 if(svustartrun>=animation["svustartrun"].length)	 
	 {	 
	 svumode = 2;	 
	 }	 
	 if(svumode==2)	 
	 {	 
	 //animation.Play("svurun", PlayMode.StopAll);	 
	 animation.CrossFade("svurun");	 
	 svustartrun = 0;	 
	 }	 
	 if(Input.GetButtonUp("Vertical")&svumode!=4)	 
	 {	 
	 svumode = 3;	 
	 animation.CrossFade("svuendrun");	 
	 }	 
	 if(svumode==3)	 
	 {	 
	 svuendrun += Time.deltaTime;	 
	 }	 
	 if(svuendrun>=animation["svuendrun"].length/1.8f)	 
	 {	 
	 svumode=0;	 
	 svuendrun = 0;	 
	 }	 
	 if(svumode==4)	 
	 {	 
	 animation.Play("svureload", PlayMode.StopAll);	 
	 svureload+=Time.deltaTime;	 
	 }	 
	 if(svureload>=animation["svureload"].length)	 
	 {	 
	 svumode = 0;	 
	 svureload = 0;	 
	 }	 
	 }	 
	 }	

Оставить комментарий