- Home /
The question is answered, right answer was accepted
Is there a way to check if something was snapped on a specific grid?
Here's the thing.
I currently have a large(large-ish) grid, with expandable areas. I would like for each expandable are to be composed of x*y grids and for any player to be able to place and/or move the objects according to the grids.
I already found a tutorial of some sort showing me how to move the object based on the grid's dimension (hope it's good though).
I would like to know if there is a possibility of checking if a specific grid already has an object snapped to it? (this is to make sure that it's not possible to snap two things on the same spot).
Regards
Answer by jwinn · Jan 21, 2013 at 01:05 AM
This is entirely dependent on what code you are using for grid snapping. You would do a check that something is not there, before allowing snapping of the current object you are moving. Or perhaps you would allow the snapping, but make the object red and not allow it to be placed.
There are several ways to check if there is an object there. You could have a trigger/collider on the already snapped object, that registers a trigger collision with your cursor or whatever you are moving around. Another way, is if you have an array storing all of the grid cells, you could have a boolean that says whether it's used (or if the type of object is stored in the array, you would just check if it is empty).
Great advice! Thank you, I think I am going to go with storing all my grids in an array as that seems to be the easiest and most efficient solution for me! I can't express my gratitude enough.
Follow this Question
Related Questions
Grid snapping 0 Answers
Create Grid and Snap Rigidbodies to Grid 1 Answer
cannot get snap to grid to activate 0 Answers
Snap to grid edge midpoints? 1 Answer
Snap to grid not working for me 1 Answer