void UpdateMove(EntityBase entity, int deltaTime) { MoveComponent mc = entity.GetComp <MoveComponent>(); SyncVector3 newPos = mc.pos.DeepCopy(); newPos.x += mc.dir.x * deltaTime * mc.m_velocity / (1000 * 1000); newPos.y += mc.dir.y * deltaTime * mc.m_velocity / (1000 * 1000); newPos.z += mc.dir.z * deltaTime * mc.m_velocity / (1000 * 1000); if (entity.GetExistComp <CollisionComponent>()) { CollisionComponent cc = entity.GetComp <CollisionComponent>(); cc.area.position = newPos.ToVector(); if (!IsCollisionBlock(cc.area)) { mc.pos = newPos; } } else { mc.pos = newPos; } }
void UpdateMove(EntityBase entity, int deltaTime) { MoveComponent mc = (MoveComponent)entity.GetComp("MoveComponent"); SyncVector3 newPos = mc.pos.DeepCopy(); newPos.x += (mc.dir.x * deltaTime / 1000) * mc.m_velocity / 1000; newPos.y += (mc.dir.y * deltaTime / 1000) * mc.m_velocity / 1000; newPos.z += (mc.dir.z * deltaTime / 1000) * mc.m_velocity / 1000; if (!entity.GetExistComp("FlyObjectComponent") && entity.GetExistComp("CollisionComponent")) { CollisionComponent cc = (CollisionComponent)entity.GetComp("CollisionComponent"); cc.area.position = newPos.ToVector(); if (!IsCollisionBlock(cc.area)) { mc.pos = newPos; } } else { mc.pos = newPos; } if (SyncDebugSystem.isDebug && SyncDebugSystem.IsFilter("MoveSystem")) { string content = "id: " + mc.Entity.ID + " m_pos " + mc.pos.ToVector() + " deltaTime " + deltaTime + " m_velocity " + mc.m_velocity + " m_dir " + mc.dir.ToVector(); //Debug.Log(content); //SyncDebugSystem.syncLog += content + "\n"; } }