public void AssignInheritedReferences() { _AttackManager = GetComponent <AttackManager>(); _HealthManager = GetComponent <HealthManager>(); // These don't have any public variables, so adding them at the runtime makes the prefab less cluttered _DamageManager = gameObject.AddComponent <DamageManager>(); _CollisionKeeper = gameObject.AddComponent <CollisionKeeper>(); _Rigidbody2D = GetComponent <Rigidbody2D>(); _Collider2D = GetComponent <CapsuleCollider2D>(); _SpriteRenderer = GetComponent <SpriteRenderer>(); _Sprite = _SpriteRenderer.sprite; var surrogatePrefab = (GameObject)Resources.Load("Prefabs/Surrogate"); var surrogate = Instantiate(surrogatePrefab); surrogate.layer = gameObject.layer; surrogate.name = $"{gameObject.name} Surrogate"; surrogate.transform.position = gameObject.transform.position; _Surrogate = surrogate.GetComponent <Surrogate>(); _Surrogate.SetOwner(gameObject); foreach (var weapon in HeldWeapons) { weapon.WeaponObject = Instantiate(weapon.WeaponPrefab, _Surrogate.gameObject.transform); weapon.WeaponObject.layer = gameObject.layer; weapon._Weapon = weapon.WeaponObject.GetComponent <Weapon>(); weapon._Weapon.Owner = gameObject; } }