Capsule.cs 1.1 KB

123456789101112131415161718192021222324
  1. using UnityEngine;
  2. /// <summary>
  3. /// Creates a CapsuleFollower object that follows this one but that has proper physics simulation.
  4. /// Used because VR controller movements don't allow for direct physics simulation.
  5. /// In the ZED VR plane detection sample, this is attached to four parts of the baseball bat used to hit the bunny.
  6. /// See CapsuleFollower.cs for more information.
  7. /// </summary>
  8. public class Capsule : MonoBehaviour
  9. {
  10. /// <summary>
  11. /// CapsuleFollower script within a prefab that contains the script, a collider, and a rigidbody.
  12. /// </summary>
  13. [SerializeField]
  14. [Tooltip("CapsuleFollower script within a prefab that contains the script, a collider, and a rigidbody.")]
  15. private CapsuleFollower capsulefollowerprefab;
  16. private void Awake()
  17. {
  18. var follower = Instantiate(capsulefollowerprefab); //Instantiate the prefab.
  19. follower.transform.position = transform.position; //Set it to this object's position.
  20. follower.SetFollowTarget(this); //Assign this as its target to follow.
  21. }
  22. }