C# Unity-新输入系统-播放器动画触发器
我试图创建一个简单的玩家动作,比如掷骰子,防止玩家滥发掷骰子。目前,我的一切工作,包括通过触发器的动画切换,但玩家可以垃圾邮件转移(滚动键),并获得无限的速度提升 这是我的第一场比赛,也是第一次参加Unity/C,所以任何/所有建设性的批评都会受到赞赏。这是我对一个简单系统的尝试:C# Unity-新输入系统-播放器动画触发器,c#,unity3d,C#,Unity3d,我试图创建一个简单的玩家动作,比如掷骰子,防止玩家滥发掷骰子。目前,我的一切工作,包括通过触发器的动画切换,但玩家可以垃圾邮件转移(滚动键),并获得无限的速度提升 这是我的第一场比赛,也是第一次参加Unity/C,所以任何/所有建设性的批评都会受到赞赏。这是我对一个简单系统的尝试: private void OnMovement(InputValue value) { Vector2 inputMovement = value.Get<Vector
private void OnMovement(InputValue value)
{
Vector2 inputMovement = value.Get<Vector2>();
_inputDirection = new Vector3(inputMovement.x, 0f, inputMovement.y);
}
private void OnRoll(InputValue value)
{
StartCoroutine(RollThePlayer());
}
public IEnumerator RollThePlayer()
{
if (canRoll)
{
PlayerAnimator.SetTrigger("Roll");
IsRolling = true;
canRoll = false;
yield return new WaitForSeconds(RollDuration);
IsRolling = false;
canRoll = true;
}
}
private void MoveThePlayer()
{
switch (_currentInput)
{
case true:
_movement.Set(_smoothDirection.x, 0f, _smoothDirection.z);
_movement = _movement.normalized * MovementSpeed * Time.deltaTime;
if (IsRolling && !canRoll)
{
_movement = _movement * RollSpeed;
}
else
{
PlayerAnimator.SetBool("Idling", false);
PlayerAnimator.SetBool("Running", true);
}
PlayerRigidbody.MovePosition(transform.position + _movement);
break;
case false:
IdleThePlayer();
break;
}
}
private void OnMovement(输入值)
{
Vector2 inputMovement=value.Get();
_inputDirection=新矢量3(inputMovement.x,0f,inputMovement.y);
}
私有void OnRoll(输入值)
{
启动例程(RollThePlayer());
}
公共IEnumerator RollThePlayer()
{
如果(可以滚动)
{
PlayerAnimator.SetTrigger(“滚动”);
IsRolling=true;
canRoll=false;
产生返回新WaitForSeconds(RollDuration);
IsRolling=false;
canRoll=true;
}
}
私有void移动层()
{
开关(电流输入)
{
大小写正确:
_移动.Set(_smoothDirection.x,0f,_smoothDirection.z);
_移动=_movement.normalized*MovementSpeed*Time.deltaTime;
如果(IsRolling&!canRoll)
{
_移动=_移动*滚动速度;
}
其他的
{
playerImator.SetBool(“空转”,false);
playerImator.SetBool(“Running”,true);
}
PlayerRigidbody.MovePosition(transform.position+_movement);
打破
案例错误:
IdleThePlayer();
打破
}
}