Exemple #1
0
        public void MoveTo(Vector3 hitPosition)
        {
            Vector3     destPosition = NavPosition(hitPosition);
            NavMeshPath navMeshPath  = new NavMeshPath();

            var navMeshAgent = _3dObj.gameObject.GetComponent <NavMeshAgent>();

            navMeshAgent.CalculatePath(destPosition, navMeshPath);

            // 能移动到该点
            if (navMeshPath.status != NavMeshPathStatus.PathPartial)
            {
                //navMeshAgent.SetDestination(destPosition);
                Proto.Move proto = new Proto.Move();
                foreach (Vector3 one in navMeshPath.corners)
                {
                    proto.Position.Add(new Proto.Vector3()
                    {
                        X = one.x, Y = one.y, Z = one.z
                    });
                }

                UnityEngine.Debug.Log($"move to. position:{destPosition}");
                NetworkMgr.GetInstance().SendPacket(Proto.MsgId.C2SMove, proto);
            }
        }
Exemple #2
0
        public void SyncMove(Google.Protobuf.IMessage msg)
        {
            Proto.Move moveProto = msg as Proto.Move;
            ulong      playerSn  = moveProto.PlayerSn;

            if (!_players.ContainsKey(playerSn))
            {
                UnityEngine.Debug.LogWarning($"sync move failed. can't find player. sn:{playerSn}");
                return;
            }

            var player        = _players[playerSn];
            var moveComponent = player.GetGameObject().GetComponent <MoveComponent>();

            moveComponent.CornerPoints.AddRange(moveProto.Position);
        }