I want to snap objects to the floor, then lock them in place so the player can snap other objects neatly adjacent to the other objects without having to fiddle with rotating it just right. I was originally going to use VRTK snapping, but I want somewhat of a freeform room furniture placement system without having to place thousands of “snap drop zones” to account for the possibilities. Is there a snapping code that works in VR?
I looked around and found this code from a YT tut: https://youtu.be/n2fx9rkMMVU
Vector3 gridSnapPos(Vector3 originalPosition)
float granularity = .1f;
Vector3 snappedPosition = new Vector3(Mathf.Floor(originalPosition.x / granularity) * granularity, originalPosition.y, Mathf.Floor(originalPosition.z / granularity) * granularity);
public void Snap()
this.transform.position = gridSnapPos(this.transform.position);
The problem I have now is that it jitters and jumps too much when grabbing it, so I made it enable on untouch and disable after running 1 frame:
enabled = false;
and whenever it’s enabled now, sitting on the floor completely still, it will jump in the -x direction.
I want it to stay put where I place it, but still allow other objects to collide with it so I can place them neatly adjacent. (edited)
Also, I tried doing rotation snapping using the same code just replacing “vector” with “quaternion” and “position” with “rotation”, doesn’t really work.
I’m trying to use it in conjunction with Fuseman’s Force tutorial: https://youtu.be/uf4sz7YbF04
This is what it currently looks like: https://youtu.be/yGpmjgf2AYs