Показать сообщение отдельно
Старый 29.12.2012, 22:21   #902
pie
ПроЭктировщик
 
Аватар для pie
 
Регистрация: 04.11.2011
Сообщений: 176
Написано 19 полезных сообщений
(для 64 пользователей)
Ответ: Вопросы от новичка

Вроде бы более-менее разобрался. Но возник вопрос. Не удается сделать один переход. Дерево выглядит так:

Переменные:

Переход SideRun -> ForwardRun:


Возникла проблема в том что не могу настроить переход ForwardRun -> SideRun. Кто может подсказать?

Код проигрывания анимации:
using UnityEngine;
using System.Collections;

[RequireComponent(typeof (Animator))]
[RequireComponent(typeof (CapsuleCollider))]
[RequireComponent(typeof (Rigidbody))]
public class AnimationController : MonoBehaviour {
	public float animSpeed = 1.5f;
	public float lookSmoother = 3f;
	public bool useCurves;

	
	private Animator anim;
	private AnimatorStateInfo currentBaseState;
	private AnimatorStateInfo layer2CurrentState;
	private CapsuleCollider col;
	private float h;
	private float s;
	
	public void Start () {
		anim = GetComponent<Animator>();					  
		col = GetComponent<CapsuleCollider>();
	}
	
	public void FixedUpdate () {
		
		var A = Input.GetKey(KeyCode.A);
		var D = Input.GetKey(KeyCode.D);
		float target = 0;
		
		if(A != D)
			target = A?-1:1;
							
		h = Mathf.SmoothDamp(h, target, ref s, 0.1f);
		//float h = Input.GetAxis("Horizontal");
		float v = Input.GetAxis("Vertical");
		
		if (v != 0) {
			anim.SetFloat("Speed", v);							
			anim.SetFloat("Direction", h);
		}else{
			anim.SetFloat("SideSpeed", Mathf.Abs(h));							
			anim.SetFloat("Direction", h);
		}
		anim.speed = animSpeed;
	}
}
(Offline)
 
Ответить с цитированием