[VR] Moving objects while snapped to the ground
Hello guys.
I am working on a Virtual Reality project using the HTC Vive. I have to create different ways of interacting with objects.
Currently i have a "Laser" on the right controller which lets the user interact with objects (Highlight,Select, Manipulate). Manipulating is like moving, rotating and scaling.
I am stuck on the moving part as i cant achieve the desired behavior.
Here is how it looks like now : link text
Here is the code i am using to place it on the ground position:
private void SnappingObject()
{
RaycastHit newHit;
if (Physics.Raycast(transform.position, transform.forward, out newHit, rayDistance, GroundLayerMask)) //to the ground - ignoring object
{
ObjectToEdit.transform.position = newHit.point;
}
}
I would like the object to not SNAP to the new position the ground raycast detects, but keep its position and move based on how much the "Laser" moved.
I tried multiple ways of fixing it but none of them worked as my trigonometry skills have slowly started to deplete when i am not using them :(. I tried calculating a the delta from the ground position found when user grabbed the object and while moving, then add the delta to the object position, but that resulted in very weird behavior.
I tried to look anywhere on the internet how this can be solved, but found nothing relative.
Anybody has any suggestions or a solution ?
Thank you very much !
Did you find an answer to that? i'm on the same page to you. i want to replicate the oculus home feature for the furniture for my own home project. to test out furniture, position it and so on.
did you managed to solve this and are willing to provide some code? working with oculus and new input system in unity.