Grab Offsets

Forums:

SnapOffset on the distance grab turned out to be somewhat frustrating and certainly warranted some additional digging. Then it dawned on me.. I was thinking about it all wrong. (which you can see if you read below on what I originally thought..rabbit hole..rabbit hole.. I left it for reference)
I could not for the life of me understand the comments of "just drag into scene hierarchy and set the offset adjusted to your hands". My first thought was "You would have a bunch of empties laying around in the scene as Vector3 references", which is the case in that scenario.
One thing to note: For it to function you must have the checkboxes for snap location and orientation checked because it looks for that in the ovr grab code. if(m_grabbedObj.snapPosition) if (m_grabbedObj.snapOrientation)
After looking at the distance grab scene "once again" I noticed that there was no "pingpong" offset or "sportbottle" offset actually in the scene but they were set on the grabbable objects. The "trick" is to create an empty object in the scene. Set the offsets that your object should use to offset from the grab point. Drag that object back down into assets (preferrable under an offsets folder) and "THAT" is the reference "prefab" to the vector3 offset values it will use. I do not recall seeing this ANYWHERE and would have saved me a ton of time of both creating in site and hand based offsets which just seemed to NOT do what I wanted. I believe this would also keep the offset values from changing as it floated around attached to whatever it is attached to. You would then just update or set the xyz values on the prefabs vector3's. I am testing this in a few seconds and will let you know if it worked or not. If so, the reference below about not flopping -offset based on which hand you are using makes sense and needs to remain. ugh... Yet another "lightbulb" moment. This does not however fix the "set and test" over "visually seeing the offset" problem, so I prefer the other solution below of setting the offset directly on the grabbable object, I just could not get it to work. This may however be the solution to that problem and if so I will add it here as well. I have also tried the snap to parent on distance grabber on hands in hierarchy but that was certainly not a solution and the object was set way above the hands.. but I will play with that as well. Not sure if it is referencing the "hand" parent object or the grabbable "object" parent object... I am thinking it is probably the latter one. I will need to play with rotation some more because it did not appear to have the effect I was expecting. I ended up rotating the Grab Point under each of the hands to get the 90 deg rotation of the grabbed object but will have to verify that snap orientation was enabled. -------------------------The sadly mistaken bits ---- Most examples just said to create an object and set it to 0,0,0 location and then adjust as needed, dragging it into the grab offset field on the distance grabbable script. Trying this I had everything from disappearing in the scene to moving the char.. ugh. Since many things will have different offsets to the hands, my first thought is that the offset should be placed on the hand under the tracking section where the controller has other grab volumns (the grabber example grabbables). This did not seem to work as expected and the other problem was that you can only have one grab offset, so how do you determine which hand is grabbling. Possibly it just uses the offset of either hand based on the name. (I have not dug into the code yet). This brought me to an interesting article by edufireheart with a different approach. Place the offset on the on the grabbable object. Totally makes sense. However, this did not work for me. After changing the code, the object disappeared when I grabbed it. I noticed there were a few comments with similar results. Thinking about the left/right multiple grab volumes may not make a difference. It should find the grab volume of the hand that is grabbing whichever that may be. That would mean that the code that minuses the X would not be needed and may be why the left appears to grab weird. (I will remark and see if that works) if (m_controller == OVRInput.Controller.LTouch) snapOffset.x = -snapOffset.x; I was almost thinking that adding a check for tag and then manually setting the offset based on the tag or type of the object.. i.e. rifle, pistol, tennis ball, burrito, etc. This way you can specifically set the exact Vector3 based on the type of object.