Readme.txt 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. How it works: Plane Detection Demo
  2. Required:
  3. -ZED_Rig_Stereo prefab.
  4. -VR Hmd with at least 1 Controller (Oculus Touch or Vive Controller).
  5. -Oculus Integration OR SteamVR Unity plugin.
  6. How to use without VR:
  7. - Open the "Simple Plane Detection" sample scene.
  8. - Look with the Zed camera somewhere on a somewhat flat surface.
  9. - Hold the "Space" bar key to start looking for a positive surface.
  10. - If the Bunny placeholder is Red, it won't be able to spawn there.
  11. - If it's Blue, then It will spawn a Bunny when the key is released from holding down.
  12. How to use with VR:
  13. - Open the "VR Only Plane Detection" sample scene.
  14. - Point with the controller towards a flat surface (floor, table etc...).
  15. - Hold the [Trigger Button] of the controller to start checking the area pointed for a positive surface.
  16. - When the Bunny Placeholder is RED, it won't be able to spawn a Bunny.
  17. - If its Blue, then you can spawn a Bunny on that surface.
  18. - Release the [Trigger Button] when the placeholder is white, to spawn a Bunny.
  19. - A baseball bat will appear at the end of the Controller.
  20. - Use it to hit the bunny and throw it as far as possible in the available space around you.
  21. Checking the variable "Can Spawn Multiple Bunnies" will no longer delete the previous Spawned Bunny.
  22. ///////////////////////////////////////////////////
  23. The Prefab "VR_Controller" contains three major scripts;
  24. ......................................................
  25. - VR_ObjectTracjer
  26. This script tracks the VR devices that can be selected through the "Device To Track" variable on the Inspector.
  27. It works for SteamVR & Oculus plugins.
  28. ......................................................
  29. - Plane Manager
  30. This script manages when to give the order to the ZED Plane Detection Manager to detect a plane at a given world space point.
  31. It checks for inputs from the VR Controllers connected, and depending on the state of that input, it starts looking for planes.
  32. Whenever the ZED Plane Detection Manager finds something, we look at how the normal of the plane it:
  33. [If the surface is horizontal enough, then proceed to spawn our Bunny]
  34. [Else, clear everything and start again]
  35. Here is also managed the display of the place holder for the Bunny.
  36. ......................................................
  37. - Bunny Spawner
  38. This script manages not only the spawning of the Bunny, but also the display of the pointerBead laser, the display of the baseball bat.
  39. The UI Panel is also spawned through here, displaying the distance traveled by the Bunny since hit by the baseball bat.
  40. ///////////////////////////////////////////////////
  41. The Prefab "Zombunny" contains the Script "Bunny", and is the object spawned when the Plane Manager finds a good plane for it.
  42. ......................................................
  43. At spawn, its Rigidbody component is not Kinematic so its allowed to interact with the baseball bat and move.
  44. When it get hits by the baseball bat, a delayed is applied before starting looking for collisions with the real world.
  45. This delay is important since the Bunny is already on the ground, so we wait for it to have moved a bit before starting detecting.
  46. ///////////////////////////////////////////////////
  47. The Prefab "Capsule_Follower" with the script of the same name.
  48. ......................................................
  49. This gameObject is set to follow other gameObject which are set as children to the baseball bat.
  50. It then calculates a velocity base on its movements towards those objects.
  51. When it collides with a Bunny;
  52. [If the vertical velocity if negative, then the bunny gets squeeze to the ground].
  53. [Else if the velocity magnitude is high enough, it gets transmited to the Bunny, which GetsHit and is sent flying].