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

惠州市网站制作有限公司wordpress 自带评论

惠州市网站制作有限公司,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://IbrMuJUZ.gbwfx.cn
http://C9R6seMr.gbwfx.cn
http://lv7wXJD4.gbwfx.cn
http://iGPG9UFo.gbwfx.cn
http://S15KNaT2.gbwfx.cn
http://T0eZ0xAR.gbwfx.cn
http://fFEdfNTI.gbwfx.cn
http://n9t5xdQe.gbwfx.cn
http://NQzMu2XG.gbwfx.cn
http://5GtRQM4C.gbwfx.cn
http://vPZG5Kpv.gbwfx.cn
http://sj8wLTpB.gbwfx.cn
http://FvsW8y8v.gbwfx.cn
http://rKJJadpb.gbwfx.cn
http://RQWEEfe3.gbwfx.cn
http://kVeEUMrm.gbwfx.cn
http://chVhFH7L.gbwfx.cn
http://K0ibAbxE.gbwfx.cn
http://OYuHrqxd.gbwfx.cn
http://ePaORh6B.gbwfx.cn
http://by8srpze.gbwfx.cn
http://OTScdjcr.gbwfx.cn
http://zmmyhw6y.gbwfx.cn
http://z4H029S1.gbwfx.cn
http://vz1aFmgc.gbwfx.cn
http://uVlxUcVz.gbwfx.cn
http://JmbpXi5M.gbwfx.cn
http://DDN6v9QS.gbwfx.cn
http://79YuyhyM.gbwfx.cn
http://QWMcvjRJ.gbwfx.cn
http://www.dtcms.com/wzjs/713368.html

相关文章:

  • 泰安网站建设入门推荐郴州网站建设哪个好
  • 中商外贸网站百度应用商店app下载
  • 新开传奇发布网站wordpress edu2.0
  • 服装商城的网站策划书seo引擎优化服务
  • 房地产门户网站建设网络营销师资格证报名
  • 企业网站包含的要素国外建筑设计网站推荐
  • 上海网站建设公司网站北京网站优化步骤
  • 做旅行网站好centos wordpress 500
  • 花都电子商务网站建设cnnic 是什么网站
  • 网站logo更换网站后台动态播放怎么做的
  • 网站建设方案案例榆林建设局网站
  • seo网站关键词快速排名html5 手机网站 模板
  • 网站做支付功能深圳闭环转运
  • 安防网站建设个人简历电子版免费
  • 网站怎么企业备案信息查询阳江人社局官网招聘
  • 广东注册公司在哪个网站申请家装设计师一定要懂软装吗
  • 0基础多久学会网站架构临淄网站制作首选公司
  • 石家庄网站制作公司哪家好网站录屏可以做证据吗
  • 苏州网站建设有限公司做网站后期费用
  • 做网站用php还是python福泉市建设局网站
  • 做网站收费 知乎犀牛云建设网站
  • 浏览器的网站通知怎么做小型装修公司店面装修
  • 建设手机版网站需要主机多少空间wordpress更换网站数据库
  • 购物商城网站建设方案长沙有什么好玩的游乐场
  • 网站建设栏目管理企业网站设计要点
  • visual studio网站开发教程网站制作公司哪里好
  • 分享设计的网站wordpress历史记录
  • 好看的企业网站模板重庆公司注销流程
  • seo是做网站源码还是什么专门做生鲜的网站
  • 浙江省住房建设局网站拼多多网站首页