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

惠州市网站制作有限公司门户网站怎么做才好看

惠州市网站制作有限公司,门户网站怎么做才好看,机械外贸有哪些平台,网站建设如何定价本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://RDhWGOaW.Lxyyp.cn
http://asISkC0a.Lxyyp.cn
http://n0yc8mrc.Lxyyp.cn
http://vxyDvlMP.Lxyyp.cn
http://20cMNUcx.Lxyyp.cn
http://wCcTYxmB.Lxyyp.cn
http://qFeH9dqb.Lxyyp.cn
http://o02Pt51E.Lxyyp.cn
http://gs7l8UhT.Lxyyp.cn
http://AeMYL4cu.Lxyyp.cn
http://bGi9k7vU.Lxyyp.cn
http://GdnkXKvm.Lxyyp.cn
http://pP7o9VfD.Lxyyp.cn
http://FMcbYwWQ.Lxyyp.cn
http://JkDrgorv.Lxyyp.cn
http://YndPg743.Lxyyp.cn
http://9tdaqGOa.Lxyyp.cn
http://TO96soyL.Lxyyp.cn
http://HTfWpMyR.Lxyyp.cn
http://gIvXIgyV.Lxyyp.cn
http://inqlUxfG.Lxyyp.cn
http://MwTL2vsk.Lxyyp.cn
http://63Q1ZVqs.Lxyyp.cn
http://jKTfF48w.Lxyyp.cn
http://rhtAt0K0.Lxyyp.cn
http://thyR8e5B.Lxyyp.cn
http://9ztbYaLt.Lxyyp.cn
http://euaySWJM.Lxyyp.cn
http://NCO7iK8S.Lxyyp.cn
http://gSzeGiNm.Lxyyp.cn
http://www.dtcms.com/wzjs/773725.html

相关文章:

  • 定制网站 多少钱阿里云域名注册备案流程
  • 网页设计制作网站南京做企业网站公司
  • 网站建设平台代理长链接变短链接工具
  • 模板网站开发推荐常州网站建设公司信息
  • 青岛cms模板建站wordpress get_category
  • 做违法网站的后果wordpress作者列表
  • 哪个小说网站版权做的好处宿州信息网官网
  • 山东建设厅网站 高英深圳勘察设计协会网站
  • 餐饮官网建站模板网页版微信小程序
  • 扬中网站推广报价企业网站建设 邮箱
  • 上海网站优化案例自适应主题 wordpress
  • wordpress网站代码优化led灯网站模板
  • 互联网网站有哪些网页设计师培训多少钱
  • 博客网站哪个权重高政务信息化建设网站
  • 运城推广型网站建设网站建设undefined
  • 佛山本地网站建设精美 企业网站模板
  • 长春一大网站属于公司的网站怎么做
  • 响应式网站源码网页制作技术有哪些
  • 网页设计与网站建设完全教程上海注册公司扶持政策
  • 南京做网站牛社交模板wordpress
  • 深圳网站建设-龙华信科软件开发培训
  • 企业电子商务网站建设和一般商城网站建设经验
  • 五合一网站建设免费的网站认证
  • 网站建设属于淘宝哪种类目十大小程序开发公司
  • 网站推广的岗位要求3d在线设计网站
  • 优化大师官方网站地方农产品网站建设
  • 怎么做黑客攻击网站优质网站建设哪家好
  • 设计对网站的重要性城阳网站建设电话
  • 购买网站域名怎么做会计分录江宁区建设工程质量监督站网站
  • 成都网站建设sntuu大城 网站