{"_id":"594967eb324098001a20d41e","project":"571fa55ca0acd42000af9545","version":{"_id":"594949e52be16d0026ec04cd","project":"571fa55ca0acd42000af9545","__v":2,"createdAt":"2017-06-20T16:14:29.816Z","releaseDate":"2017-06-20T16:14:29.816Z","categories":["594949e62be16d0026ec04ce","594949e62be16d0026ec04cf","594949e62be16d0026ec04d0","594949e62be16d0026ec04d1","594949e62be16d0026ec04d2","594949e62be16d0026ec04d3","594949e62be16d0026ec04d4","594949e62be16d0026ec04d5","594949e62be16d0026ec04d6","594949e62be16d0026ec04d7","594949e62be16d0026ec04d8","594949e62be16d0026ec04d9","594949e62be16d0026ec04da","594949e62be16d0026ec04db","594949e62be16d0026ec04dc","594949e62be16d0026ec04dd","594949e62be16d0026ec04de","594949e62be16d0026ec04df","594949e62be16d0026ec04e0","594949e62be16d0026ec04e1","59497219f4a8980024dd0631"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Kunekune","version_clean":"3.2.0","version":"3.2.0"},"category":{"_id":"594949e62be16d0026ec04db","version":"594949e52be16d0026ec04cd","project":"571fa55ca0acd42000af9545","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T17:01:47.129Z","from_sync":false,"order":13,"slug":"utilities","title":"Utilities"},"user":"571fa519db52d01700f5cf3d","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-06-20T18:22:35.095Z","link_external":false,"link_url":"","githubsync":"","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 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 CapsuleCast method is used to generate a linecast either from the given CustomRaycast object or a default Physics.Linecast.\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.","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 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 CapsuleCast method is used to generate a linecast either from the given CustomRaycast object or a default Physics.Linecast. ### 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.