Hey Guys,
I am very new to unity and am building a VR app for Oculus Go. I want to pick and move the object by pointing the ray from the controller on the object and then picking or releasing it by pressing the trigger button. I want the object to stay fixed at the end of the ray’s position rather than coming suddenly onto the controller.
If anyone could point me in a right direction or help me with this, I would greatly appreciate it!
Thanks in advance.
I did something like this early on. I don’t think there was any magic to it… on trigger down, cast a ray from the controller into the world, and see what it hits. If it hits something, store the transform of the gameobject hit (or some parent that has a component or tag you’re looking for to indicate “portable objects”) on a property of the script, along with the position of the ray hit relative to that object’s transform, and the distance of this point from the controller.
Then on every frame while the trigger is down, do the inverse math — calculate the point that same distance in front of the controller, use InverseTransformPoint to calculate the position of the object, and move the held object there. If you’re using physics, then you should do the movement with Rigidbody.MovePosition; otherwise just set the Transform.position.
Hey, thanks.
I tried but could not exactly get it. Do you have any sample script that could help me with it?
Thanks a lot once again for the help.
You can use the Avatar SDK from Oculus and set the hands to grabber and the item to grabbed (There should be a script somewhere). Then it works with the trigger as you want
I am also stuck in this problem… if i found the solution will post here
All of the stuff @JoeStrout mentioned above is dealt with in the “learn” page of unity in an easy to learn form for beginners. Everything else he mentioned in the post is non-vr specific and again, is dealt with in the unity tutorials.
I recommend going and doing that and then coming back, otherwise your effectively asking people to write your entire application for you. If you cant do this you will struggle with the next feature you design, and the one after that etc etc.
Gotta grasp the basics of space flight first before trying to fly to the moon.
please share the link
thanks in advance
You arent even willing to google “unity tutorials”?
https://unity3d.com/learn/tutorials
FYI your going to need to be more proactive than this in your searching for problems if you want to actually see any project through to the end