Snap-to function in Unity?
I am busy with a game that requires a snap-to function for the moveable tokens in the game.
As a novice coder I have been able to get the tokens to snap to position using a snap-to script tutorial. The problem is that the script is placed on the tokens and controlled by the mouse/touch. This is a difficult way of doing it, and the tokens do not stay in place if slightly bumped.
Can anyone help with advice on a simpler script that would be placed on the blue dot position, that would snap any object to it, if place on top of it as per the video clip.
As a novice coder I have been able to get the tokens to snap to position using a snap-to script tutorial. The problem is that the script is placed on the tokens and controlled by the mouse/touch. This is a difficult way of doing it, and the tokens do not stay in place if slightly bumped.
Can anyone help with advice on a simpler script that would be placed on the blue dot position, that would snap any object to it, if place on top of it as per the video clip.
Comments
I will try the first point.
Was just wanting to try find simpler code that could be placed on the blue dots and not on the tokens.
The Alternative point sounds good... but not sure how to implement as a novice coder.
But it sounds like you are approaching this wrong by having scripts on each of the tokens, or even the goal of one on each of the dots. I would treat the whole thing as a "board" and have one script that handles the tokens and possible position they can snap in to.
Just a difficult task for a novice coder looking for a simple solution. Guess simple solutions and coding don't do well in Unity, as I have been told many times. Have a funtastic weekend.
https://github.com/plyoung/token-snap-example
That looks pretty spot on for what the game would require in terms of snap-to.
If that is what you code quickly in your spare time, then my hat off to you.... it looks awesome. ;)
I will study how you did this, and try to implement it and see if I can get it to work.
Thank you once again for the time you put into this.