当前位置: 首页 > wzjs >正文

惠州市网站制作有限公司制作网站先做前端还是后端

惠州市网站制作有限公司,制作网站先做前端还是后端,wordpress会员中心插件,河南艾特网站建设本Demo基础来自于: 【阿严】[Unity]平台跳跃游戏 角色控制器 教程合集 | 状态机架构 | Platformer Controller Tutorial Collection_哔哩哔哩_bilibili 阿严的Github地址:https://github.com/AtCloudStudio/PlatformerControllerTutorial 我的实现:通过网盘分享的文件&#xf…

        本Demo基础来自于:

【阿严】[Unity]平台跳跃游戏 角色控制器 教程合集 | 状态机架构 | Platformer Controller Tutorial Collection_哔哩哔哩_bilibili

阿严的Github地址:https://github.com/AtCloudStudio/PlatformerControllerTutorial 

我的实现:通过网盘分享的文件:3D下的2D控制器精髓.7z
链接: https://pan.baidu.com/s/1B-XHXM0a9VzVTrJbL3uctw?pwd=1234 提取码: 1234 

         本Demo的重点:

目录

1.新输入系统

2. FSM的so文件化

3.土狼时间

4.输入预处理(跳跃)


思维导图

状态机及玩家基本组件部分 

玩家具体状态实现 

 

视频介绍:

Unity 一个3D下的2D平台跳跃控制器

        因为实现起来还是比较简单无痛的 所以具体请查看源码 我只是将代码放在这里 并不会做更多的解释

1.新输入系统

using System.Collections;
using Unity.VisualScripting;
using UnityEngine;public class PlayerInput : MonoBehaviour
{private InputSystem_Actions inputActions;[SerializeField, InspectorLabel("跳跃缓冲自动无效时间")] private float jumpInputBufferTime = 0.5f;public Vector2 Axis => inputActions.Player.Move.ReadValue<Vector2>();public float MoveX_input => Axis.x;public bool isMove_input => MoveX_input != 0;public bool isJump_input => inputActions.Player.Jump.WasPerformedThisFrame();public bool StopJump_input => inputActions.Player.Jump.WasReleasedThisFrame();//土狼时间public bool hasJumpInputBuffer { get; set; }private void Awake(){inputActions = new InputSystem_Actions();}public void EnableInputSystem(){inputActions.Player.Enable();Cursor.lockState = CursorLockMode.Locked;// 注册 当玩家松开跳跃键时,就会触发canceled这个回调inputActions.Player.Jump.canceled += (de) =>{hasJumpInputBuffer = false;};}void OnGUI(){Rect rect = new Rect(200, 200, 200, 200);string message = "Has Jump Input Buffer: " + hasJumpInputBuffer;GUIStyle style = new GUIStyle();style.fontSize = 20;style.fontStyle = FontStyle.Bold;GUI.Label(rect, message, style);}public void ResetJumpBuffer(){StopCoroutine(DoRestJumpBuffer());StartCoroutine(DoRestJumpBuffer());}public IEnumerator DoRestJumpBuffer(){hasJumpInputBuffer = true;yield return new WaitForSeconds(jumpInputBufferTime);hasJumpInputBuffer = false;}public void DisableInputSystem(){inputActions.Player.Disable();}
}

2. FSM的so文件化

using UnityEngine;public class PlayerState : ScriptableObject, IState
{protected Animator animator;protected PlayerInput playerInput;protected PlyaerStateMachine playerStateMachine;protected PlayerController playerController;#region 动画参数[SerializeField] private string animationClipName; //动画名称[SerializeField, Range(0, 1f)] private float crossFadeTime = 0.1f;private int stateHash;protected float startTime;protected float StateDurtion => Time.time - startTime;protected bool IsAnimationFinished => StateDurtion >= animator.GetCurrentAnimatorStateInfo(0).length;#endregion#region 继承参数protected float currentSpeed;#endregion/// <summary>/// 初始化/// </summary>/// <param name="stateMachine">状态机对象</param>/// <param name="animator">动画组件</param>/// <param name="playerInput">玩家输入类对象</param>/// <param name="playerController">玩家控制类对象</param>public void Init(PlyaerStateMachine stateMachine, Animator animator, PlayerInput playerInput,PlayerController playerController){this.animator = animator;this.playerStateMachine = stateMachine;this.playerInput = playerInput;this.playerController = playerController;}private void OnEnable(){stateHash = Animator.StringToHash(animationClipName);}public virtual void Enter(){animator.CrossFadeInFixedTime(animationClipName, crossFadeTime);startTime = Time.time;}public virtual void Exit() { }public virtual void FixedUpdate() { }public virtual void Update() { }
}

3.土狼时间

using UnityEngine;
[CreateAssetMenu(menuName = "Player/States/Player_CoyoteTime")]
public class Player_CoyoteTime : PlayerState
{public float runSpeed = 5f;public float coyoteTime = 0.2f;public override void Enter(){base.Enter();playerController.SetUesGravity(false);}public override void Update(){//土狼时间:让玩家在空中悬浮一小段时间 还是可以跳跃if (playerInput.isJump_input){playerStateMachine.ChangeState(typeof(Player_JumpUp));}//只有在超过过土狼时间以后 或者不输入以后才会下落if (StateDurtion >= coyoteTime || !playerInput.isMove_input){playerStateMachine.ChangeState(typeof(Player_JumpFall));}}public override void FixedUpdate(){//currentSpeed同步减速playerController.Move2Clip(runSpeed);}public override void Exit(){playerController.SetUesGravity(true);}
}

4.输入预处理(跳跃)

        在PlayerInput里

    public void ResetJumpBuffer(){StopCoroutine(DoRestJumpBuffer());StartCoroutine(DoRestJumpBuffer());}public IEnumerator DoRestJumpBuffer(){hasJumpInputBuffer = true;yield return new WaitForSeconds(jumpInputBufferTime);hasJumpInputBuffer = false;}

http://www.dtcms.com/wzjs/615658.html

相关文章:

  • 长沙企业网站开发链家网
  • 网站开发协助方案电脑课做网站所需的软件
  • 大兴网站建设一条龙国外优秀创意的个人网页设计欣赏
  • 上海地区网站建设广东制作公司网站
  • 常州做网站找哪家好wordpress完整迁移
  • 怎么做网站的营销制作网站 优帮云
  • 网站设计自学wordpress的数据库有多大
  • 建设专业网站哪家技术好网站因备案关闭
  • 马和人做人和牛做网站中国最好室内设计公司排名榜
  • wordpress页面发布不深圳关键词优化软件
  • 网站建设知名公司排名产品设计方案范本
  • 开封网站建设公司微信网站建设平台
  • 网站备案域名所有人长沙网络营销整合收费
  • 南通网站建设南通施工企业环保应急预案
  • 网站建设找嘉艺网络反向代理服务器做wordpress外网
  • 东莞网站关键词三亚网吧多少钱一个小时
  • 什么是网站seowordpress 伪原创插件
  • 做网站全国最大wordpress 修改页面链接地址
  • 网站建设卖东西购买网站平台如何做分录
  • 免费网站建设 源代码高端品牌网站建设集团
  • 接私活 做网站中国有限公司官网
  • 杂志媒体网站建设方案wordpress 底部备案号
  • 个人网站可以备案了吗学做电商新手入门
  • 织梦采集侠官方网站重庆网站推广产品企业
  • 整站网站优化费用模板网站建设公司电话
  • 扬州网站商城建设价格表国内四大高端建站公司
  • 做外贸网站价格谁知道免费网站
  • 做标识的网站 知乎哪个网站可以做加工代理的
  • 网站维护的内容和步骤网络推广方案范文
  • 建立公司微信平台 网站平台搜索百度网址网页