using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
private Animator player;
void Start()
{
player = GetComponent<Animator>();
}
{
player = GetComponent<Animator>();
}
void FixedUpdate()
{
float h = -Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
{
float h = -Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
//这些都是unity设定好的,如果忘记可通过以下途径查看
player.SetFloat("deriction", h);
player.SetFloat("speed", v);
player.SetFloat("speed", v);
if (Input.GetButton("Fire1"))
{
player.SetBool("reloading", true);
}
else
{
player.SetBool("reloading", false);
}
{
player.SetBool("reloading", true);
}
else
{
player.SetBool("reloading", false);
}
if (Input.GetButton("Fire2"))
{
player.SetBool("swap",true);
}
else
{
player.SetBool("swap", false);
}
}
}
{
player.SetBool("swap",true);
}
else
{
player.SetBool("swap", false);
}
}
}
这里要注意的是在idle状态与各个状态间的has Exit Time的勾给去掉,这样才能做到无间隙切换,否则要等Idle动画播放完才能切换到其他动画,会出现许多bug