Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

35 行
1.0 KiB

using UnityEngine;
namespace GameplayIngredients.Controllers
{
public class SimplePlayerInput : PlayerInput
{
[Header("Movement")]
public string MovementHorizontalAxis = "Horizontal";
public string MovementVerticalAxis = "Vertical";
[Header("Look")]
public string LookHorizontalAxis = "Mouse X";
public string LookVerticalAxis = "Mouse Y";
[Header("Buttons")]
public string JumpButton = "Jump";
public override Vector2 Look => m_Look;
public override Vector2 Movement => m_Movement;
public override ButtonState Jump => m_Jump;
Vector2 m_Movement;
Vector2 m_Look;
ButtonState m_Jump;
public override void UpdateInput()
{
m_Movement = new Vector2(Input.GetAxis(MovementHorizontalAxis), Input.GetAxis(MovementVerticalAxis));
m_Look = new Vector2(Input.GetAxis(LookHorizontalAxis), Input.GetAxis(LookVerticalAxis));
m_Jump = GetButtonState(JumpButton);
}
}
}