public override void OnTriggerEnter(Collider collider) { UnitPlayer player = collider.gameObject.GetComponent <UnitPlayer>(); if (player != null) { if (differentPrefabOnly && targetPrefab.prefabID == player.prefabID) { return; } if (targetTransform == null) { targetTransform = transform; } GameObject newplayerObj = (GameObject)Instantiate(targetPrefab.gameObject, targetTransform.position, targetTransform.rotation); GameControl.SetPlayer(newplayerObj.GetComponent <UnitPlayer>()); //for effect, check parent class if (!spawnEffectAtOrigin) { effPos = player.transform.position; } targetEffPos = targetTransform.position; Destroy(collider.gameObject); Triggered(); } }