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

Netcode for GameObjects Boss Room 多人RPG战斗(12)

ClientCharacter.cs

1. 完整代码

usingSystem;usingUnity.BossRoom.CameraUtils;usingUnity.BossRoom.Gameplay.UserInput;usingUnity.BossRoom.Gameplay.Configuration;usingUnity.BossRoom.Gameplay.Actions;usingUnity.BossRoom.Utils;usingUnity.Netcode;usingUnityEngine;namespaceUnity.BossRoom.Gameplay.GameplayObjects.Character{/// <summary>/// <see cref="ClientCharacter"/> is responsible for displaying a character on the client's screen based on state information sent by the server./// </summary>publicclassClientCharacter:NetworkBehaviour{[SerializeField]Animatorm_ClientVisualsAnimator;[SerializeField]VisualizationConfigurationm_VisualizationConfiguration;/// <summary>/// Returns a reference to the active Animator for this visualization/// </summary>publicAnimatorOurAnimator=>m_ClientVisualsAnimator;/// <summary>/// Returns the targeting-reticule prefab for this character visualization/// </summary>publicGameObjectTargetReticulePrefab=>m_VisualizationConfiguration.TargetReticule;/// <summary>/// Returns the Material to plug into the reticule when the selected entity is hostile/// </summary>publicMaterialReticuleHostileMat=>m_VisualizationConfiguration.ReticuleHostileMat;/// <summary>/// Returns the Material to plug into the reticule when the selected entity is friendly/// </summary>publicMaterialReticuleFriendlyMat=>m_VisualizationConfiguration.ReticuleFriendlyMat;CharacterSwapm_CharacterSwapper;publicCharacterSwapCharacterSwap=>m_CharacterSwapper;publicboolCanPerformActions=>m_ServerCharacter.CanPerformActions;ServerCharacterm_ServerCharacter;publicServerCharacterserverCharacter=>m_ServerCharacter;ClientActionPlayerm_ClientActionViz;PositionLerperm_PositionLerper;RotationLerperm_RotationLerper;// this value suffices for both positional and rotational interpolations; one may have a constant value for eachconstfloatk_LerpTime=0.08f;Vector3m_LerpedPosition;Quaternionm_LerpedRotation;floatm_CurrentSpeed;/// <summary>/// /// Server to Client RPC that broadcasts this action play to all clients./// </summary>/// <param> Data about which action to play and its associated details. </param>[Rpc(SendTo.ClientsAndHost)]publicvoidClientPlayActionRpc(ActionRequestDatadata){ActionRequestDatadata1=data;m_ClientActionViz.PlayAction(refdata1);}/// <summary>/// This RPC is invoked on the client when the active action FXs need to be cancelled (e.g. when the character has been stunned)/// </summary>[Rpc(SendTo.ClientsAndHost)]publicvoidClientCancelAllActionsRpc(){m_ClientActionViz.CancelAllActions();}/// <summary>/// This RPC is invoked on the client when active action FXs of a certain type need to be cancelled (e.g. when the Stealth action ends)/// </summary>[Rpc(SendTo.ClientsAndHost)]publicvoidClientCancelActionsByPrototypeIDRpc(ActionIDactionPrototypeID){m_ClientActionViz.CancelAllActionsWithSamePrototypeID(actionPrototypeID);}/// <summary>/// Called on all clients when this character has stopped "charging up" an attack./// Provides a value between 0 and 1 inclusive which indicates how "charged up" the attack ended up being./// </summary>[Rpc(SendTo.ClientsAndHost)]publicvoidClientStopChargingUpRpc(floatpercentCharged){m_ClientActionViz.OnStoppedChargingUp(percentCharged);}voidAwake(
http://www.cnnetsun.cn/news/116561.html

相关文章:

  • Netcode for GameObjects Boss Room 多人RPG战斗(19)
  • 深度学习优化器算法巧思速览
  • macOS上优雅运行Docker容器
  • XXL-JOB分布式任务调度
  • MYSQL与B+树与索引相关面试题
  • PostgreSQL pgvector扩展Windows环境完整安装指南
  • Steam游戏挂机神器:3分钟学会自动刷时长和交易卡
  • F5 Big-IP by SNMP.硬件负载均衡
  • 公有云省钱 + 稳业务秘诀!自动伸缩 1 节课上手,资源不浪费、高峰不卡顿~(4)
  • EmotiVoice WebSocket接口设计与调用示例
  • 基于51单片机的颜色识别报站系统设计
  • 3个关键策略解决Cocos事件响应混乱问题
  • DuckDB C++集成:如何在嵌入式项目中实现高性能数据分析?
  • 移动端集成EmotiVoice:Android/iOS兼容方案
  • Feishin音乐播放器完全手册:打造个性化自托管音乐云
  • Launcher3 启动器:打造纯净原生 Android 体验的完整指南
  • 同花顺问财数据获取:Python自动化工具的完整使用指南
  • 【完整指南】快速掌握ComfyUI-SeedVR2视频超分模块
  • 大模型重塑知识图谱构建全面解析LLMs驱动的知识工程新范式!
  • 云存储安全防线:OSS防御体系构建与实战策略
  • SUNNOD喷墨打印机防堵头测试色卡:专业维护解决方案
  • 通义千问3-VL-Plus - 界面交互(本地图片)
  • 使用C#代码更改 PowerPoint 幻灯片大小
  • 基于单片机的智能电动车设计
  • Shipit自动化部署终极指南:从零到精通完整教程
  • Freedom Chat | 这款美国通讯应用泄露了所有人的电话号码
  • JMeter 二次开发环境准备详解
  • OkHttp跨平台网络开发实战指南:从架构原理到性能优化
  • 2025有哪些免费降ai率工具?有哪些免费AI率查重工具?
  • 大模型应用开发-Langchain(V1-最新版)-上