Exemple #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.L))
        {
            _humanLocked = !_humanLocked;
        }

        if (_humans.Count > 0)
        {
            if (human != null && _humanLocked && _humans.ContainsKey(human.id))
            {
                human = _humans[human.id];
            }
            else
            {
                _humanLocked = false;
                Vector3 surface  = _projectionScript.getSurfaceBaryCenter();
                Human   newHuman = null;
                foreach (Human h in _humans.Values)
                {
                    if (newHuman == null)
                    {
                        newHuman = h;
                    }
                    else
                    {
                        if (Vector3.Distance(h.body.Joints[BodyJointType.head], surface) < Vector3.Distance(newHuman.body.Joints[BodyJointType.head], surface))
                        {
                            newHuman = h;
                        }
                    }
                }
                human = newHuman;
            }
            Camera.main.transform.position = human.body.Joints[BodyJointType.head];
        }

        // finally
        _cleanDeadHumans();
    }