playMaker

Author Topic: Puzzle mechanics (collect a torn letter)  (Read 247 times)

Fitbie

  • Playmaker Newbie
  • *
  • Posts: 25
Puzzle mechanics (collect a torn letter)
« on: August 10, 2022, 01:20:30 PM »
Hi! My game should have this mechanic: player finds a torn letter, after interacting with it starts a minigame (I think to do it in the UI), the player must compose a letter from the torn pieces. I'm without ideas how to implement this, I was thinking of Grid Layout, but even with that there are no ideas. And even better if it wasn't hard to coordinate, and the pieces somehow checked the location relative to each other (without grid layout), but I don't even know where to start. Can anyone help?

wetcircuit

  • Full Member
  • ***
  • Posts: 154
    • wetcircuit.com
Re: Puzzle mechanics (collect a torn letter)
« Reply #1 on: August 10, 2022, 02:19:52 PM »
Maybe look for a jigsaw puzzle asset, see how they did it?
I have seen UI grids where images can be dragged and dropped.

Another method could be 'snapping' where an edge of the torn paper has a mate on another fragment's edge, if the edges are brought close they will 'snap' together.

Fitbie

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Puzzle mechanics (collect a torn letter)
« Reply #2 on: August 11, 2022, 08:55:34 AM »

Another method could be 'snapping' where an edge of the torn paper has a mate on another fragment's edge, if the edges are brought close they will 'snap' together.
Yes, that's what I meant. I would like to know at least tips on what actions or components to use
I mean should I put colliders and RigitBody2 on the Image UI and check contacts? Or maybe there is another way to know if 2 UI objects collide
« Last Edit: August 11, 2022, 03:38:21 PM by Fitbie »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7031
    • jinxtergames
Re: Puzzle mechanics (collect a torn letter)
« Reply #3 on: August 13, 2022, 03:00:45 AM »
Hi.

This video might give you an idea on how you can set this up.





basically have objects with 2d colliders with the same name as each piece (probably make the colliders smaller than the puzzle piece , then with trigger2d events get the colliding object and compare the name.
If the same, get the position of the collider and then set that position to the puzzle piece (later you can add some "move Toward" or "Tween Position" to animate it moving to that position instead if insta snapping to that position.

LeDisciple

  • Playmaker Newbie
  • *
  • Posts: 26
Re: Puzzle mechanics (collect a torn letter)
« Reply #4 on: August 14, 2022, 02:22:45 PM »
Hi,

My first tought if I'm gonna do that it's with some id and UIposition. when your torn part is inside the UIgiven position (with an average in xyz coordinates) and place itself at good place when click up or touch up(if android) and use a bool arraylist or hashtable to know if a pieces is it in good place or not until every pieces are in their specific places. Good luck
« Last Edit: August 14, 2022, 03:34:07 PM by LeDisciple »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7031
    • jinxtergames
Re: Puzzle mechanics (collect a torn letter)
« Reply #5 on: August 14, 2022, 11:42:30 PM »
Hi.
I would not recommend using UI for it, it will be a lot harder to add animations / vfx stuff