摘要: 场景中添加一只野猪 将素材中的野猪图片进行切割,然后给野猪绑定刚体和碰撞体 注意需要两个碰撞体 第一个碰撞体在脚底,避免野猪掉下去,为了避免这个碰撞体和其它敌人以及玩家产生碰撞,需要排除 Player 和 Enemy 层,这样这个碰撞体就只会和平台产生碰撞,避免野猪掉下去 第二个碰撞体表示野猪的攻击 阅读全文
posted @ 2024-02-24 13:09 hellozjf 阅读(47) 评论(0) 推荐(0) 编辑
摘要: 动画片段 做成动画片段,命名为 blueCrouchStart 和 blueCrouchIdle 动画状态机 这里我们再接触一个新的东西,Sub-State Machine,可以通过右键 Create Sub-State Machine 来实现 点开 Crouch ,把之前创建好的 blueCrou 阅读全文
posted @ 2024-02-24 12:29 hellozjf 阅读(52) 评论(0) 推荐(0) 编辑
摘要: 人物跳跃的五个阶段 根据这张图把图片切好,并做好动画状态 使用 BlendTree 实现跳跃动画 在动画状态机中新建一个 BlendTree,然后给它添加三个 Motion 因为我设置的 JumpForce 是 5,所以人物速度54时候是起跳阶段,41的时候是上升阶段,1~-1的时候是空中换腿阶段, 阅读全文
posted @ 2024-02-24 11:52 hellozjf 阅读(59) 评论(0) 推荐(0) 编辑
摘要: 目标 按住键盘上的 左shift 键,或者手柄上的 左肩键 后,人物行动速度变为原来的 1/5,这样就能够强制走路了 配置 inputControl 实现相关代码 private void Awake() { // 获取 Player 上面的刚体组件 rb = GetComponent<Rigidb 阅读全文
posted @ 2024-02-24 10:51 hellozjf 阅读(56) 评论(0) 推荐(0) 编辑
摘要: 给帧图片命名 添加动画 首先需要给 Player 添加 Animator 组件 然后创建 Animations/Player 文件夹,并在该文件夹下面添加 Animator Controller,起名叫 Player 然后把 Player 拖到 Animator 的 Controller 上面 打开 阅读全文
posted @ 2024-02-24 04:32 hellozjf 阅读(42) 评论(0) 推荐(0) 编辑
摘要: 物理环境监测代码 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PhysicsCheck : MonoBehaviour { [Header("监测参数")] p 阅读全文
posted @ 2024-02-24 03:34 hellozjf 阅读(33) 评论(0) 推荐(0) 编辑
摘要: InputAction 添加跳跃键 代码实现 using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; usi 阅读全文
posted @ 2024-02-24 03:05 hellozjf 阅读(62) 评论(0) 推荐(0) 编辑
摘要: 代码实现 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Scripting.APIUpda 阅读全文
posted @ 2024-02-24 02:21 hellozjf 阅读(35) 评论(0) 推荐(0) 编辑
摘要: 创建脚本 文件夹路径 新建 PlayerController 脚本 升级新的输入系统 Api Compatibility Level 改为 .NET Framework,这样可以利用更多的 C# 特性 Active Input Handling 改为 Input System Package (Ne 阅读全文
posted @ 2024-02-23 21:23 hellozjf 阅读(41) 评论(0) 推荐(0) 编辑
摘要: 添加刚体 在 Rigidbody 2D 上面有 Gravity Scale,这表示人物收到的重力比例是1。重力参数可以通过 Project Settings -> Physics 2D,找到 Gravity 的系数。此外物理更新的 Fixed Update 函数会进入,就是因为 Simulation 阅读全文
posted @ 2024-02-23 15:52 hellozjf 阅读(43) 评论(0) 推荐(0) 编辑