这是第一个 Unity 开放项目的repo,是 Unity 和社区合作创建的一个小型开源游戏演示,第一款游戏是一款名为 Chop Chop 的动作冒险游戏。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

38 行
1.2 KiB

using UnityEngine;
using UnityEngine.PlayerLoop;
/// <summary>
/// <para>This class is a data holder that the <c>StateMachine</c> class uses to deposit data that needs to be shared between states.
/// Ideally, both the player character and NPCs can use this component to drive locomotion.</para>
/// <para>Also used to listen to the native Unity Message <c>OnControllerColliderHit</c> from the <c>CharacterController</c> component,
/// which requires a <c>MonoBehaviour</c> to be listened to.</para>
/// </summary>
public class Character : MonoBehaviour
{
//These fields are manipulated by the StateMachine actions
[HideInInspector] public bool jumpInput;
[HideInInspector] public Vector3 movementInput; //Initial input coming from the Protagonist script
[HideInInspector] public Vector3 movementVector; //Final movement vector, manipulated by the StateMachine actions
[HideInInspector] public ControllerColliderHit lastHit;
private void OnControllerColliderHit(ControllerColliderHit hit)
{
lastHit = hit;
}
//---- COMMANDS ISSUED BY OTHER SCRIPTS ----
public void Move(Vector3 movement)
{
movementInput = movement;
}
public void Jump()
{
jumpInput = true;
}
public void CancelJump()
{
jumpInput = false;
}
}