Пример #1
0
    void Update()
    {
        if (!isServer)
        {
            temp         = server_pos;
            server_pos.x = CONSTANTS.decomp_pos(syncx_compressed);
            server_pos.y = CONSTANTS.decomp_pos(syncy_compressed);


            propRB.velocity = (server_pos - temp).normalized * CONSTANTS.decomp_pos(syncspeed_compressed);
            interpolator.interpolate(server_pos);

            //propRB.angularVelocity = syncrotvel;
            interpolator.interpolate_rot(syncrot);
        }
        else
        {
            sync_server();

            /*
             * if(CONSTANTS.comp_pos(propRB.position.x) != syncx_compressed)
             * {
             *  syncx_compressed = CONSTANTS.comp_pos(propRB.position.x);
             * }
             * if (CONSTANTS.comp_pos(propRB.position.y) != syncy_compressed)
             * {
             *  syncy_compressed = CONSTANTS.comp_pos(propRB.position.y);
             * }
             * if (CONSTANTS.comp_pos(propRB.velocity.x) != syncvelx_compressed)
             * {
             *  syncvelx_compressed = CONSTANTS.comp_pos(propRB.velocity.x);
             * }
             * if (CONSTANTS.comp_pos(propRB.velocity.y) != syncvely_compressed)
             * {
             *  syncvely_compressed = CONSTANTS.comp_pos(propRB.velocity.y);
             * }
             * if(propRB.rotation != syncrot)
             * {
             *  syncrot = transform.rotation.eulerAngles.z;
             * }
             * if(propRB.angularVelocity != syncrotvel)
             * {
             *  syncrotvel = propRB.angularVelocity;
             * }
             */
        }
    }