同步位置放大1000倍取整
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Node, Vec3, Tween, tween } from 'cc';
|
||||
import { Position } from '../../Shared/protocols/base';
|
||||
import { Node, Tween, tween, Vec3 } from 'cc';
|
||||
import { RoleController } from '../../CC/RoleController';
|
||||
import { Position } from '../../Shared/protocols/base';
|
||||
|
||||
/**
|
||||
* RemotePlayer 远程玩家
|
||||
@@ -38,8 +38,10 @@ export class RemotePlayer {
|
||||
this.playerNode = playerNode;
|
||||
this.playerId = playerId;
|
||||
this.playerName = playerName;
|
||||
this.currentPosition.set(position.x, 0, position.y);
|
||||
this.targetPosition.set(position.x, 0, position.y);
|
||||
const x = position.x / 1000
|
||||
const y = position.y / 1000
|
||||
this.currentPosition.set(x, 0, y);
|
||||
this.targetPosition.set(x, 0, y);
|
||||
|
||||
// 获取 RoleController 组件
|
||||
this.roleController = this.playerNode.getComponentInChildren(RoleController);
|
||||
@@ -58,7 +60,7 @@ export class RemotePlayer {
|
||||
* 收到服务器广播的移动消息时调用
|
||||
*/
|
||||
public updatePosition(position: Position): void {
|
||||
this.targetPosition.set(position.x, 0, position.y);
|
||||
this.targetPosition.set(position.x / 1000, 0, position.y / 1000);
|
||||
|
||||
// 计算移动方向和距离
|
||||
const direction = this.targetPosition.clone().subtract(this.currentPosition);
|
||||
|
||||
Reference in New Issue
Block a user