InputModule.HandleNetInput C# (CSharp) Method

HandleNetInput() public method

public HandleNetInput ( JsonData jsonData, Vector3 &targetVel ) : void
jsonData JsonData
targetVel Vector3
return void
    public override void HandleNetInput(JsonData jsonData, ref Vector3 targetVel)
    {
        Debug.Log (jsonData.ToJSON ());
        // Get movement
        _myAvatar.sendSceneInfo = jsonData["send_scene_info"].ReadBool(false);
        cacheVel = _myAvatar.moveSpeed * jsonData["vel"].ReadVector3(Vector3.zero);
        targetVel = cacheVel;
        cacheAngVel = _myAvatar.rotSpeed * jsonData["ang_vel"].ReadVector3(Vector3.zero);
        if (jsonData["teleport_random"].ReadBool(false))
            _myAvatar.TeleportToValidPosition();
        _myAvatar.shouldCollectObjectInfo = jsonData["get_obj_data"].ReadBool(false);
        List<string> relationships = new List<string>();
        if (!jsonData["relationships"].ReadList(ref relationships))
        {
            string testStr = null;
            if (jsonData["relationships"].ReadString(ref testStr) && testStr != null && testStr.ToUpper() == "ALL")
                relationships.Add(testStr);
        }
        _myAvatar.relationshipsToRetrieve = relationships;
        // Apply Magic
        JsonData actionsList = jsonData["actions"];
        if (actionsList != null) {
            int actionsCount = actionsList.Count;
            SemanticObject[] allObjects = UnityEngine.Object.FindObjectsOfType<SemanticObject>();
            for (int i = 0; i < actionsCount; i++) {
                JsonData action = actionsList [i];
                string id = action ["id"].ReadString ();
                Vector3 force = action ["force"].ReadVector3 ();
                force = _myAvatar.transform.TransformDirection (force);
                Vector3 torque = action ["torque"].ReadVector3 ();
                torque = _myAvatar.transform.TransformDirection (torque);
                foreach (SemanticObject o in allObjects) {
                    string idval = NetMessenger.colorUIDToString(o.gameObject.GetComponentInChildren<Renderer> ().material.GetColor ("_idval"));
                    if (idval == id) {
                        Rigidbody rb = o.gameObject.GetComponentInChildren<Rigidbody> ();
                        rb.AddForce (force);
                        rb.AddTorque (torque);
                    }
                }
            }
        }
    }