private void instantiateRoomObjectGameObject(string name, Vector2 position) { GameObject roomObjectGameObject = new GameObject(name); RoomObject roomObject = getRoomObjectFromDirectory(name); RoomObjectUI roomObjectUI = roomObjectGameObject.AddComponent <RoomObjectUI>(); roomObjectUI.setupRoomObjectGameObject(roomObjectGameObject, roomObject); roomObjectGameObject.transform.position = position; }
private void OnTriggerEnter2D(Collider2D collision) { RoomObjectUI other = collision.gameObject.GetComponent <RoomObjectUI>(); if (other != null) //if collided thing has Object component, need to check if it's tall enough to collide { if (height < other.getHeight()) { destroyProjectile(); } } else { destroyProjectile(); } }