Skip to content

Commit 5ecea3a

Browse files
committed
防止跳转场景后有位置拉扯现象
1 parent 9131f02 commit 5ecea3a

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

Assets/Scripts/kbe_scripts/Avatar.cs

316 Bytes
Binary file not shown.

Assets/Scripts/u3d_scripts/GameEntity.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class GameEntity : MonoBehaviour
1313
private Vector3 _position = Vector3.zero;
1414
private Vector3 _eulerAngles = Vector3.zero;
1515
private Vector3 _scale = Vector3.zero;
16+
private UInt32 _spaceID = 0;
1617

1718
public Vector3 destPosition = Vector3.zero;
1819
public Vector3 destDirection = Vector3.zero;
@@ -152,6 +153,18 @@ public float speed {
152153
}
153154
}
154155

156+
public UInt32 spaceID {
157+
get
158+
{
159+
return _spaceID;
160+
}
161+
162+
set
163+
{
164+
_spaceID = value;
165+
}
166+
}
167+
155168
public void entityEnable()
156169
{
157170
entityEnabled = true;
@@ -189,7 +202,7 @@ void FixedUpdate ()
189202
if(isPlayer == isControlled)
190203
return;
191204

192-
KBEngine.Event.fireIn("updatePlayer", gameObject.transform.position.x,
205+
KBEngine.Event.fireIn("updatePlayer", spaceID, gameObject.transform.position.x,
193206
gameObject.transform.position.y, gameObject.transform.position.z, gameObject.transform.rotation.eulerAngles.y);
194207
}
195208

Assets/Scripts/u3d_scripts/World.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@ public void set_position(KBEngine.Entity entity)
188188
if(entity.renderObj == null)
189189
return;
190190

191-
((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().destPosition = entity.position;
192-
((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().position = entity.position;
191+
GameEntity gameEntity = ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>();
192+
gameEntity.destPosition = entity.position;
193+
gameEntity.position = entity.position;
194+
gameEntity.spaceID = KBEngineApp.app.spaceID;
193195
}
194196

195197
public void updatePosition(KBEngine.Entity entity)
@@ -200,6 +202,7 @@ public void updatePosition(KBEngine.Entity entity)
200202
GameEntity gameEntity = ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>();
201203
gameEntity.destPosition = entity.position;
202204
gameEntity.isOnGround = entity.isOnGround;
205+
gameEntity.spaceID = KBEngineApp.app.spaceID;
203206
}
204207

205208
public void onControlled(KBEngine.Entity entity, bool isControlled)
@@ -216,8 +219,9 @@ public void set_direction(KBEngine.Entity entity)
216219
if(entity.renderObj == null)
217220
return;
218221

219-
((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>().destDirection =
220-
new Vector3(entity.direction.y, entity.direction.z, entity.direction.x);
222+
GameEntity gameEntity = ((UnityEngine.GameObject)entity.renderObj).GetComponent<GameEntity>();
223+
gameEntity.destDirection = new Vector3(entity.direction.y, entity.direction.z, entity.direction.x);
224+
gameEntity.spaceID = KBEngineApp.app.spaceID;
221225
}
222226

223227
public void set_HP(KBEngine.Entity entity, object v)

0 commit comments

Comments
 (0)