news 2026/1/2 11:36:40

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
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(
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2025/12/30 14:46:00

RustDesk隐私保护技术深度解析:企业级远程协助的安全屏障

RustDesk隐私保护技术深度解析&#xff1a;企业级远程协助的安全屏障 【免费下载链接】rustdesk 一个开源的远程桌面&#xff0c;是TeamViewer的替代选择。 项目地址: https://gitcode.com/GitHub_Trending/ru/rustdesk 在数字化转型加速的今天&#xff0c;远程桌面工具…

作者头像 李华
网站建设 2025/12/30 8:44:38

神经网络和深度学习 第二周:神经网络基础(一)回归基础

周的课程以逻辑回归为例详细介绍了神经网络的运行&#xff0c;传播等过程&#xff0c;其中涉及大量机器学习的基础知识和部分数学原理&#xff0c;如没有一定的相关基础&#xff0c;理解会较为困难。 因为&#xff0c;笔记并不直接复述视频原理&#xff0c;而是从基础开始&…

作者头像 李华
网站建设 2025/12/31 2:56:59

Visio终极形状库:免费完整版一键导入技巧

Visio终极形状库&#xff1a;免费完整版一键导入技巧 【免费下载链接】史上最全Visio形状库分享 你是否在使用Microsoft Visio时&#xff0c;发现内置的形状库无法满足你的需求&#xff1f;你是否在寻找一个更全面、更丰富的形状库来提升你的绘图效率&#xff1f;那么&#xff…

作者头像 李华
网站建设 2025/12/31 2:56:57

多角度AI视觉革命:自然语言重塑图像视角控制新纪元

多角度AI视觉革命&#xff1a;自然语言重塑图像视角控制新纪元 【免费下载链接】Qwen-Edit-2509-Multiple-angles 项目地址: https://ai.gitcode.com/hf_mirrors/dx8152/Qwen-Edit-2509-Multiple-angles 在数字创意日益重要的今天&#xff0c;图像视角控制已成为内容创…

作者头像 李华
网站建设 2025/12/31 2:56:55

5大实战技巧:重新定义DeepSeek大模型推理性能

5大实战技巧&#xff1a;重新定义DeepSeek大模型推理性能 【免费下载链接】DeepSeek-V3.2-Exp DeepSeek-V3.2-Exp是DeepSeek推出的实验性模型&#xff0c;基于V3.1-Terminus架构&#xff0c;创新引入DeepSeek Sparse Attention稀疏注意力机制&#xff0c;在保持模型输出质量的同…

作者头像 李华
网站建设 2025/12/31 2:56:53

【Web第三周】『12.9-12.14』

【Web第三周】『12.9-12.14』 1.初步了解数据库&#xff08;MySQL&#xff09; 2.初步了解sql注入漏洞 3.练习sql语句 4.搭建sql靶场&#xff0c;找不到的&#xff0c;靶场文件群文件有 1、MySQL …

作者头像 李华