Object Manipulation

From ETC Public Wiki
Jump to: navigation, search

Object Manipulation (Daydream Elements)

Firstly, the Ideal Daydream Setup:






........Main Camera


............Controller Visual



Make the above a prefab and it makes things a lot easier to manage inside of Unity as it separates the Daydream GOs from normal GOs.

To use the Object Manipulation feature on top of this, simply get the Daydream Elements project from here: https://github.com/googlevr/daydream-elements and then use the ObjectManipulationPointer prefab to replace the GvrControllerPointer.

To make objects respond to the pointer, simply add the "MoveablePhysicsObject" script (also found in the elements project above) to the object. It'll automatically add a rigidbody to the object. But you also need a collider apart from that.

The MoveablePhysicsObject class is present in the Daydream.ObjectManipulation namespace.

To change the distances with which the pointer affects objects, you'll have to do them in individual objects. Modify the min/max distance in the object's MoveablePhysicsObject script. Also for the swipe (scrolling on the touchpad to make the object come closer towards / move further away from you), if you don't want that to happen, set the Swipe increment to 0. Or else, change it to a suitable value if so desired.

You can always look at the debug rays (in the SCENE window) by enabling them inside the ObjectManipulationPointer game object's child - the Laser. (There should be a checkbox that says "draw debug rays"). The min max distances that exist in the ObjectManipulationPointer script on this game object will NOT affect how the pointer touches objects at that distance, it just deals with the rendering.

To check if an object is selected (being manipulated by the pointer) or not, use the "State" property which is defined in the base class of the MoveablePhysicsObject class. It has a public get which makes it accessible from other scripts if you use relevantObject.GetComponent<Daydream.ObjectManipulation.MoveablePhysicsObject>().State.