Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How to autolock a position using the OnMouseUp?

Discussion in 'Getting Started' started by Wilx600, Nov 8, 2023.

  1. Wilx600


    Sep 13, 2023
    I'm fairly new to Unity so I don't know much, but I'm trying to make a jigsaw and my problem is, that I want a piece of my puzzle to auto-lock to the correct position it belongs to when I let go of the mouse, for example, if I put the piece where it belongs like on the top right of the puzzle it will click into place. I tried going at it by using the OnMouseUp, first I placed some placeholders and added a tag to it and the puzzle piece, and made it so that when I let go it checks if the two tags are the same, if it is a puzzle piece new vector2(x,y) also a debug.log saying Its The Same. But when I do that and drag it over to the spot it doesn't change its vector, all it does is trigger the log anytime I let go of the piece not just on the specific placeholder.