得意黑字体安装
This commit is contained in:
1 parent
d0144205c4
commit
3ae43d1297
39 files changed
+8628
-817
No files matched your search
@@ -4,14 +4,14 @@ using UnityEngine;
|
||||
/// 用 UI 虚拟摇杆(移动轮盘)驱动角色移动,替代原来的点击地面移动。
|
||||
///
|
||||
/// 用法:挂在带 CharacterController 的角色上,把场景里的 <see cref="VirtualJoystick"/>
|
||||
/// 拖到 joystick 字段(留空会在运行时自动查找)。
|
||||
/// 拖到 joystick 字段(在 Inspector / 预制体里接线,代码里不查找节点)。
|
||||
/// 摇杆方向默认按摄像机朝向换算成世界方向,推杆越满速度越快;只做水平移动,y 不变。
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(CharacterController))]
|
||||
public class PlayerMoveController : MonoBehaviour
|
||||
{
|
||||
[Header("输入")]
|
||||
[Tooltip("移动轮盘;留空则在运行时自动查找场景中的 VirtualJoystick")]
|
||||
[Tooltip("移动轮盘;必须在 Inspector / 预制体里指定,留空角色不会移动")]
|
||||
[SerializeField] private VirtualJoystick joystick;
|
||||
|
||||
[Tooltip("是否按摄像机朝向移动(关掉则按世界坐标轴移动)")]
|
||||
@@ -37,16 +37,9 @@ public class PlayerMoveController : MonoBehaviour
|
||||
private void Awake()
|
||||
{
|
||||
_controller = GetComponent<CharacterController>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 场景里只有一个轮盘时自动接管,省得手动拖引用
|
||||
if (joystick == null)
|
||||
joystick = FindFirstObjectByType<VirtualJoystick>(FindObjectsInactive.Include);
|
||||
|
||||
if (joystick == null)
|
||||
Debug.LogWarning("[PlayerMoveController] 场景里没找到 VirtualJoystick(移动轮盘),角色不会移动。");
|
||||
Debug.LogError("[PlayerMoveController] 没有指定移动轮盘(joystick),请在 Inspector / 预制体里拖入。", this);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
Reference in new issue
Block a user