Example #1
0
    private void Start()
    {
        //Head.centerOfMass += HeadMassOffset;

        LegLeft.Awake();
        LegLeft.Orientation = -1;
        LegLeft.Player      = this;

        LegRight.Awake();
        LegRight.Orientation = 1;
        LegRight.Player      = this;


        {               // ignore self collisions
            Physics2D.IgnoreCollision(HeadCollider, LegLeft.Collider);
            Physics2D.IgnoreCollision(HeadCollider, LegRight.Collider);
            Physics2D.IgnoreCollision(LegLeft.Collider, LegRight.Collider);
        }

        if (GameplayManager.Instance == null)
        {
            PlayerId = _playerCount++;
            {
                // set the controller. currently only works the first time when loaded in a scene
                var controllers = InputManager.Devices.ToList();
                if (PlayerId < controllers.Count)
                {
                    Controller = controllers[PlayerId];
                }
                else
                {
                    Debug.LogFormat("Player{0} missing controller", PlayerId);
                }
            }
        }
    }