替换武器模型
将原来武器的参数附给新的武器
解决薛定谔的枪
实现死亡动画
在Player里
public class Player : NetworkBehaviour
{
//返回角色的死亡信息,如果是死亡就不刷新direction为0;
public bool GetIsDied()
{
return isDied.Value;
}
//带有延时的重生函数
private IEnumerator Respawn() {
GetComponentInChildren<Animator>().SetInteger("direction", 0);
GetComponent<Rigidbody>().useGravity = true;
...
}
//具体的死亡逻辑,缴械
private void Die()
{
GetComponentInChildren<Animator>().SetInteger("direction", -1);
//当死亡时重力消失
GetComponent<Rigidbody>().useGravity = false;
...
}
}
在PlayerController类里
public class PlayerController : NetworkBehaviour
{
...
private void PerformAnimation()
{
...
//如果是死就赋成-1;
if (GetComponent<Player>().GetIsDied())
{
direction = -1;
}
animator.SetInteger("direction", direction);
}
}
实现跳跃动画
在PlayerController里
public class PlayerController : NetworkBehaviour
{
...
private float distToGround = 0f;
void Start()
{
...
distToGround = GetComponent<Collider>().bounds.extents.y;
}
private void PerformAnimation()
{
...
if(!Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1f))
{
direction = 8;
}
animator.SetInteger("direction", direction);
}
...
}