news 2026/6/11 6:35:29

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进行投诉反馈,一经查实,立即删除!
网站建设 2026/6/10 12:43:56

工业设备振动预测不准 后来才知道加小波变换分解多频段特征

&#x1f493; 博客主页&#xff1a;借口的CSDN主页 ⏩ 文章专栏&#xff1a;《热点资讯》 目录AI&#xff1a;我的脑洞比你大 一、创业者的“人工智障”操作 二、AI入侵我的日常生活 1. 智能音箱的“社恐”时刻 2. 医疗AI的“选择困难症” 3. 电商平台的“读心术” 三、AI创作…

作者头像 李华
网站建设 2026/6/9 21:10:19

22、Sendmail 的特殊 m4 配置:从地址重写到中继客户端配置

Sendmail 的特殊 m4 配置:从地址重写到中继客户端配置 1. 地址伪装与通用表 地址伪装是 Sendmail 的一个重要特性,它可以将发件人地址的主机部分重写为标准值,以用于所有外发邮件。 MASQUERADE_DOMAIN 宏和 masquerade_entire_domain 特性允许通用表( genericstable…

作者头像 李华
网站建设 2026/6/10 18:54:34

JVM面试题相关-中级

问题 1&#xff1a;JVM 是什么&#xff1f;它的主要作用是什么&#xff1f;问题 2&#xff1a;JVM 的整体架构由哪些部分组成&#xff1f;问题 3&#xff1a;JVM 运行时数据区中&#xff0c;堆和栈的核心区别是什么&#xff1f;问题 4&#xff1a;类加载的全过程分为哪几个阶段…

作者头像 李华
网站建设 2026/6/10 3:53:21

2025年UI框架架构深度解析:从设计哲学到工程实践

2025年UI框架架构深度解析&#xff1a;从设计哲学到工程实践 【免费下载链接】marko A declarative, HTML-based language that makes building web apps fun 项目地址: https://gitcode.com/gh_mirrors/ma/marko 引言&#xff1a;架构决策的技术本质 在当今快速演进的…

作者头像 李华