[Chip]Unity开发笔记--Input System实现跳跃,冲刺

本文详细介绍了如何在Unity中使用InputSystem配置移动和冲刺功能,包括Jump和Dash动作的设置,以及相应的C#脚本编写,涉及碰撞检测和状态管理。

0.基础配置

 基础配置在上一期中有介绍

[Chip]Unity开发笔记--Input System实现移动

1.Input Actions配置

1.在Actions中右键Add Action命名为Jump,Action Type为Button。

2.右键Jump选择Add Binding,在右侧Path中选择Listen按下空格键,即可将空格键绑定为跳跃所需的按键。

3.同理Add Action命名为Dash,将Shift键绑定为冲刺所需的按键。

配置完后如图所示

4.保存后关闭窗口。

2.跳跃代码编写

1.右键Create一个C# Scrpt命名为Jump,并挂载到Player身上。

2.初始化PlayerControl

public class Jump : MonoBehaviour
{
    public PlayerControl playerControl;
    private void Awake()
    {
        playerControl = new PlayerControl();
    }
    private void OnEnable()
    {
        playerControl.Enable();
    }
    private void OnDisable()
    {
        playerControl.Di
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值