void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.layer == LayerMask.NameToLayer("Ground")) { GameObject scrapInstance = Instantiate <GameObject>(scrapPrefab, transform.position, Quaternion.identity); CollectFromGround script = scrapInstance.GetComponent <CollectFromGround>(); script.Init(character, distanceThreshold, acceleration); Destroy(gameObject); } }
private void configurePrefab() { CollectFromGround script = scrapPrefab.GetComponent<CollectFromGround>(); script.Init(character, distanceThreshold, acceleration); }