- Home /
Puzzle level completed how to move to next level
hi i'm looking for a way to progress from level to level in a drag and drop word game i've been building and i need a way for the game to check if the tiles are in position before the level moves on.
the tiles can only go into the right position so i am hoping for a way just to check that the tiles are in position before moving to the next level
if anyone could show me a way to do this i would be very greatful, thank you.
Answer by SzalonyNiemiec · Dec 12, 2018 at 11:43 PM
the easiest way to do this is to assign each tile a goal position, and then check if all tiles are in the desired position in the method you call when clicking the "Submit Answer" button.
you make empty GameObjects and put one in each field where you put the tiles. You assign these positions to the tiles, by adding "public GameObject desiredPosition;" or "public GameObject[] desiredPositions;" to your tile-script, and then you drag and drop the positionObjects in the Unity Editor into the corresponding tile scripts. you check the distance with "Vector3.Distance(this.transform.position, desiredPosition.transform.position)"
thank you so much you've really helped me out