public override IEnumerator Interact() { yield return(base.Interact()); // Couple action & animations MovingInteractable top = sm.SpawnMovingInteractable(spawnedTop, this.movementSpeed, this.movementVec, transform.position.x, transform.position.y + 0.1f); MovingInteractable bottom = sm.SpawnMovingInteractable(spawnedBottom, this.movementSpeed, this.movementVec, transform.position.x, transform.position.y - 0.1f); top.Push(coupleBreakForce); bottom.Push(-coupleBreakForce); Destroy(gameObject); }
public MovingInteractable SpawnMovingInteractable(GameObject prefab, float movespeed, Vector2 moveVec, float spawnX, float spawnY) { GameObject spawned = Instantiate(prefab, spawnParent); MovingInteractable spawnedMI = spawned.GetComponent <MovingInteractable>(); spawnedMI.movementSpeed = movespeed; spawnedMI.transform.position = new Vector2(spawnX, spawnY); spawnedMI.movementVec = moveVec; spawnedMI.cm = cm; if (spawnedMI.GetType().Equals(typeof(Couple))) { ((Couple)spawnedMI).sm = this; } return(spawnedMI); }