{"_id":"5b1f8576c2505d00031254cc","project":"571fa55ca0acd42000af9545","version":{"_id":"5b1f8576c2505d00031254db","project":"571fa55ca0acd42000af9545","__v":4,"forked_from":"594949e52be16d0026ec04cd","createdAt":"2017-06-20T16:14:29.816Z","releaseDate":"2017-06-20T16:14:29.816Z","categories":["5b1f8576c2505d0003125424","5b1f8576c2505d0003125425","5b1f8576c2505d0003125426","5b1f8576c2505d0003125427","5b1f8576c2505d0003125428","5b1f8576c2505d0003125429","5b1f8576c2505d000312542a","5b1f8576c2505d000312542b","5b1f8576c2505d000312542c","5b1f8576c2505d000312542d","5b1f8576c2505d000312542e","5b1f8576c2505d000312542f","5b1f8576c2505d0003125430","5b1f8576c2505d0003125431","5b1f8576c2505d0003125432","5b1f8576c2505d0003125433","5b1f8576c2505d0003125434","5b1f8576c2505d0003125435","5b1f8576c2505d0003125436","5b1f8576c2505d0003125437","5b1f8576c2505d0003125438","5b1f8aab9c683000032979e7","5b1f8b2f3073470003ffa5da","5b1f8bd9fd653400031d94f4","5b1f900bd4c5f000036b57bd"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Mangalica","version_clean":"3.3.0","version":"3.3.0"},"category":{"_id":"5b1f8576c2505d0003125431","version":"5b1f8576c2505d00031254db","project":"571fa55ca0acd42000af9545","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T17:01:47.129Z","from_sync":false,"order":14,"slug":"utilities","title":"Utilities"},"user":"571fa519db52d01700f5cf3d","githubsync":"","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-06-20T18:22:35.095Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":8,"body":"## Overview\n\nA Custom Raycast allows to specify custom options for a Physics.Raycast.\n\nA number of other scripts can utilise a Custom Raycast to further customise the raycasts that the scripts use internally.\n\nFor example, the VRTK_BodyPhysics script can be set to ignore trigger colliders when casting to see if it should teleport up or down to the nearest floor.\n\n## Inspector Parameters\n\n * **Layers To Ignore:** The layers to ignore when raycasting.\n * **Trigger Interaction:** Determines whether the ray will interact with trigger colliders.\n\n## Class Methods\n\n### Raycast/6\n\n  > `public static bool Raycast(VRTK_CustomRaycast customCast, Ray ray, out RaycastHit hitData, LayerMask ignoreLayers, float length = Mathf.Infinity, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)`\n\n * Parameters\n   * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters.\n   * `Ray ray` - The Ray to cast with.\n   * `out RaycastHit hitData` - The raycast hit data.\n   * `LayerMask ignoreLayers` - A layermask of layers to ignore from the raycast.\n   * `float length` - The maximum length of the raycast.\n   * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast.\n * Returns\n   * `bool` - Returns true if the raycast successfully collides with a valid object.\n\nThe Raycast method is used to generate a raycast either from the given CustomRaycast object or a default Physics.Raycast.\n\n### Linecast/6\n\n  > `public static bool Linecast(VRTK_CustomRaycast customCast, Vector3 startPosition, Vector3 endPosition, out RaycastHit hitData, LayerMask ignoreLayers, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)`\n\n * Parameters\n   * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters.\n   * `Vector3 startPosition` - The world position to start the linecast from.\n   * `Vector3 endPosition` - The world position to end the linecast at.\n   * `out RaycastHit hitData` - The linecast hit data.\n   * `LayerMask ignoreLayers` - A layermask of layers to ignore from the linecast.\n   * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast.\n * Returns\n   * `bool` - Returns true if the linecast successfully collides with a valid object.\n\nThe Linecast method is used to generate a linecast either from the given CustomRaycast object or a default Physics.Linecast.\n\n### CapsuleCast/9\n\n  > `public static bool CapsuleCast(VRTK_CustomRaycast customCast, Vector3 point1, Vector3 point2, float radius, Vector3 direction, float maxDistance, out RaycastHit hitData, LayerMask ignoreLayers, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)`\n\n * Parameters\n   * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters.\n   * `Vector3 point1` - The center of the sphere at the start of the capsule.\n   * `Vector3 point2` - The center of the sphere at the end of the capsule.\n   * `float radius` - The radius of the capsule.\n   * `Vector3 direction` - The direction into which to sweep the capsule.\n   * `float maxDistance` - The max length of the sweep.\n   * `out RaycastHit hitData` - The capsulecast hit data.\n   * `LayerMask ignoreLayers` - A layermask of layers to ignore from the capsulecast.\n   * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast.\n * Returns\n   * `bool` - Returns true if the capsulecast successfully collides with a valid object.\n\nThe CapsuleCast method is used to generate a capsulecast either from the given CustomRaycast object or a default Physics.CapsuleCast.\n\n### BoxCast/9\n\n  > `public static bool BoxCast(VRTK_CustomRaycast customCast, Vector3 center, Vector3 halfExtents, Vector3 direction, Quaternion orientation, float maxDistance, out RaycastHit hitData, LayerMask ignoreLayers, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)`\n\n * Parameters\n   * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters.\n   * `Vector3 center` - The center of the box.\n   * `Vector3 halfExtents` - Half the size of the box in each dimension.\n   * `Vector3 direction` - The direction in which to cast the box.\n   * `Quaternion orientation` - The rotation of the box.\n   * `float maxDistance` - The max length of the cast.\n   * `out RaycastHit hitData` - The boxcast hit data.\n   * `LayerMask ignoreLayers` - A layermask of layers to ignore from the boxcast.\n   * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast.\n * Returns\n   * `bool` - Returns true if the boxcast successfully collides with a valid object.\n\nThe BoxCast method is used to generate a boxcast either from the given CustomRaycast object or a default Physics.BoxCast.\n\n### CustomRaycast/3\n\n  > `public virtual bool CustomRaycast(Ray ray, out RaycastHit hitData, float length = Mathf.Infinity)`\n\n * Parameters\n   * `Ray ray` - The Ray to cast with.\n   * `out RaycastHit hitData` - The raycast hit data.\n   * `float length` - The maximum length of the raycast.\n * Returns\n   * `bool` - Returns true if the raycast successfully collides with a valid object.\n\nThe CustomRaycast method is used to generate a raycast based on the options defined in the CustomRaycast object.\n\n### CustomLinecast/3\n\n  > `public virtual bool CustomLinecast(Vector3 startPosition, Vector3 endPosition, out RaycastHit hitData)`\n\n * Parameters\n   * `Vector3 startPosition` - The world position to start the linecast from.\n   * `Vector3 endPosition` - The world position to end the linecast at.\n   * `out RaycastHit hitData` - The linecast hit data.\n * Returns\n   * `bool` - Returns true if the line successfully collides with a valid object.\n\nThe CustomLinecast method is used to generate a linecast based on the options defined in the CustomRaycast object.\n\n### CustomCapsuleCast/6\n\n  > `public virtual bool CustomCapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, float maxDistance, out RaycastHit hitData)`\n\n * Parameters\n   * `Vector3 point1` - The center of the sphere at the start of the capsule.\n   * `Vector3 point2` - The center of the sphere at the end of the capsule.\n   * `float radius` - The radius of the capsule.\n   * `Vector3 direction` - The direction into which to sweep the capsule.\n   * `float maxDistance` - The max length of the sweep.\n   * `out RaycastHit hitData` - The capsulecast hit data.\n * Returns\n   * `bool` - Returns true if the capsule successfully collides with a valid object.\n\nThe CustomCapsuleCast method is used to generate a capsulecast based on the options defined in the CustomRaycast object.\n\n### CustomBoxCast/6\n\n  > `public virtual bool CustomBoxCast(Vector3 center, Vector3 halfExtents, Vector3 direction, Quaternion orientation, float maxDistance, out RaycastHit hitData)`\n\n * Parameters\n   * `Vector3 center` - The center of the box.\n   * `Vector3 halfExtents` - Half the size of the box in each dimension.\n   * `Vector3 direction` - The direction in which to cast the box.\n   * `Quaternion orientation` - The rotation of the box.\n   * `float maxDistance` - The max length of the cast.\n   * `out RaycastHit hitData` - The boxcast hit data.\n * Returns\n   * `bool` - Returns true if the box successfully collides with a valid object.\n\nThe CustomBoxCast method is used to generate a boxcast based on the options defined in the CustomRaycast object.","excerpt":"","slug":"vrtk_customraycast","type":"basic","title":"VRTK_CustomRaycast"}

VRTK_CustomRaycast


## Overview A Custom Raycast allows to specify custom options for a Physics.Raycast. A number of other scripts can utilise a Custom Raycast to further customise the raycasts that the scripts use internally. For example, the VRTK_BodyPhysics script can be set to ignore trigger colliders when casting to see if it should teleport up or down to the nearest floor. ## Inspector Parameters * **Layers To Ignore:** The layers to ignore when raycasting. * **Trigger Interaction:** Determines whether the ray will interact with trigger colliders. ## Class Methods ### Raycast/6 > `public static bool Raycast(VRTK_CustomRaycast customCast, Ray ray, out RaycastHit hitData, LayerMask ignoreLayers, float length = Mathf.Infinity, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)` * Parameters * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters. * `Ray ray` - The Ray to cast with. * `out RaycastHit hitData` - The raycast hit data. * `LayerMask ignoreLayers` - A layermask of layers to ignore from the raycast. * `float length` - The maximum length of the raycast. * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast. * Returns * `bool` - Returns true if the raycast successfully collides with a valid object. The Raycast method is used to generate a raycast either from the given CustomRaycast object or a default Physics.Raycast. ### Linecast/6 > `public static bool Linecast(VRTK_CustomRaycast customCast, Vector3 startPosition, Vector3 endPosition, out RaycastHit hitData, LayerMask ignoreLayers, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)` * Parameters * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters. * `Vector3 startPosition` - The world position to start the linecast from. * `Vector3 endPosition` - The world position to end the linecast at. * `out RaycastHit hitData` - The linecast hit data. * `LayerMask ignoreLayers` - A layermask of layers to ignore from the linecast. * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast. * Returns * `bool` - Returns true if the linecast successfully collides with a valid object. The Linecast method is used to generate a linecast either from the given CustomRaycast object or a default Physics.Linecast. ### CapsuleCast/9 > `public static bool CapsuleCast(VRTK_CustomRaycast customCast, Vector3 point1, Vector3 point2, float radius, Vector3 direction, float maxDistance, out RaycastHit hitData, LayerMask ignoreLayers, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)` * Parameters * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters. * `Vector3 point1` - The center of the sphere at the start of the capsule. * `Vector3 point2` - The center of the sphere at the end of the capsule. * `float radius` - The radius of the capsule. * `Vector3 direction` - The direction into which to sweep the capsule. * `float maxDistance` - The max length of the sweep. * `out RaycastHit hitData` - The capsulecast hit data. * `LayerMask ignoreLayers` - A layermask of layers to ignore from the capsulecast. * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast. * Returns * `bool` - Returns true if the capsulecast successfully collides with a valid object. The CapsuleCast method is used to generate a capsulecast either from the given CustomRaycast object or a default Physics.CapsuleCast. ### BoxCast/9 > `public static bool BoxCast(VRTK_CustomRaycast customCast, Vector3 center, Vector3 halfExtents, Vector3 direction, Quaternion orientation, float maxDistance, out RaycastHit hitData, LayerMask ignoreLayers, QueryTriggerInteraction affectTriggers = QueryTriggerInteraction.UseGlobal)` * Parameters * `VRTK_CustomRaycast customCast` - The optional object with customised cast parameters. * `Vector3 center` - The center of the box. * `Vector3 halfExtents` - Half the size of the box in each dimension. * `Vector3 direction` - The direction in which to cast the box. * `Quaternion orientation` - The rotation of the box. * `float maxDistance` - The max length of the cast. * `out RaycastHit hitData` - The boxcast hit data. * `LayerMask ignoreLayers` - A layermask of layers to ignore from the boxcast. * `QueryTriggerInteraction affectTriggers` - Determines the trigger interaction level of the cast. * Returns * `bool` - Returns true if the boxcast successfully collides with a valid object. The BoxCast method is used to generate a boxcast either from the given CustomRaycast object or a default Physics.BoxCast. ### CustomRaycast/3 > `public virtual bool CustomRaycast(Ray ray, out RaycastHit hitData, float length = Mathf.Infinity)` * Parameters * `Ray ray` - The Ray to cast with. * `out RaycastHit hitData` - The raycast hit data. * `float length` - The maximum length of the raycast. * Returns * `bool` - Returns true if the raycast successfully collides with a valid object. The CustomRaycast method is used to generate a raycast based on the options defined in the CustomRaycast object. ### CustomLinecast/3 > `public virtual bool CustomLinecast(Vector3 startPosition, Vector3 endPosition, out RaycastHit hitData)` * Parameters * `Vector3 startPosition` - The world position to start the linecast from. * `Vector3 endPosition` - The world position to end the linecast at. * `out RaycastHit hitData` - The linecast hit data. * Returns * `bool` - Returns true if the line successfully collides with a valid object. The CustomLinecast method is used to generate a linecast based on the options defined in the CustomRaycast object. ### CustomCapsuleCast/6 > `public virtual bool CustomCapsuleCast(Vector3 point1, Vector3 point2, float radius, Vector3 direction, float maxDistance, out RaycastHit hitData)` * Parameters * `Vector3 point1` - The center of the sphere at the start of the capsule. * `Vector3 point2` - The center of the sphere at the end of the capsule. * `float radius` - The radius of the capsule. * `Vector3 direction` - The direction into which to sweep the capsule. * `float maxDistance` - The max length of the sweep. * `out RaycastHit hitData` - The capsulecast hit data. * Returns * `bool` - Returns true if the capsule successfully collides with a valid object. The CustomCapsuleCast method is used to generate a capsulecast based on the options defined in the CustomRaycast object. ### CustomBoxCast/6 > `public virtual bool CustomBoxCast(Vector3 center, Vector3 halfExtents, Vector3 direction, Quaternion orientation, float maxDistance, out RaycastHit hitData)` * Parameters * `Vector3 center` - The center of the box. * `Vector3 halfExtents` - Half the size of the box in each dimension. * `Vector3 direction` - The direction in which to cast the box. * `Quaternion orientation` - The rotation of the box. * `float maxDistance` - The max length of the cast. * `out RaycastHit hitData` - The boxcast hit data. * Returns * `bool` - Returns true if the box successfully collides with a valid object. The CustomBoxCast method is used to generate a boxcast based on the options defined in the CustomRaycast object.