Skip to content

Commit 2e4616a

Browse files
committed
fix(Teleport): use the nav mesh check distance value in SamplePosition
The nav mesh check using `NavMesh.SamplePosition` was using a hard coded max position of `0.1f` rather than the optional parameter, so the parameter was only acting as a toggle instead of providing granual control. This has now been fixed so the parameter is used as the `maxDistance`.
1 parent 356b09d commit 2e4616a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

Assets/VRTK/Scripts/Abstractions/VRTK_WorldPointer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ protected virtual bool ValidDestination(Transform target, Vector3 destinationPos
364364
if (target)
365365
{
366366
NavMeshHit hit;
367-
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, 0.1f, NavMesh.AllAreas);
367+
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, navMeshCheckDistance, NavMesh.AllAreas);
368368
}
369369
if (navMeshCheckDistance == 0f)
370370
{

Assets/VRTK/Scripts/VRTK_BasicTeleport.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class VRTK_BasicTeleport : MonoBehaviour
3333
public string ignoreTargetWithTagOrClass;
3434
[Tooltip("A specified VRTK_TagOrScriptPolicyList to use to determine whether destination targets will be acted upon by the Teleporter. If a list is provided then the 'Ignore Target With Tag Or Class' parameter will be ignored.")]
3535
public VRTK_TagOrScriptPolicyList targetTagOrScriptListPolicy;
36-
[Tooltip("The max distance the nav mesh edge can be from the teleport destination to be considered valid. If a value of `0` is given then the nav mesh restriction will be ignored.")]
36+
[Tooltip("The max distance the teleport destination can be outside the nav mesh to be considered valid. If a value of `0` is given then the nav mesh restrictions will be ignored.")]
3737
public float navMeshLimitDistance = 0f;
3838

3939
/// <summary>
@@ -144,7 +144,7 @@ protected virtual bool ValidLocation(Transform target, Vector3 destinationPositi
144144
if (target)
145145
{
146146
NavMeshHit hit;
147-
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, 0.1f, NavMesh.AllAreas);
147+
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, navMeshLimitDistance, NavMesh.AllAreas);
148148
}
149149
if (navMeshLimitDistance == 0f)
150150
{

DOCUMENTATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,7 @@ The Basic Teleport script is attached to the `[CameraRig]` prefab.
20792079
* **Headset Position Compensation:** If this is checked then the teleported location will be the position of the headset within the play area. If it is unchecked then the teleported location will always be the centre of the play area even if the headset position is not in the centre of the play area.
20802080
* **Ignore Target With Tag Or Class:** A string that specifies an object Tag or the name of a Script attached to an object and notifies the teleporter that the destination is to be ignored so the user cannot teleport to that location. It also ensure the pointer colour is set to the miss colour.
20812081
* **Target Tag Or Script List Policy:** A specified VRTK_TagOrScriptPolicyList to use to determine whether destination targets will be acted upon by the Teleporter. If a list is provided then the 'Ignore Target With Tag Or Class' parameter will be ignored.
2082-
* **Nav Mesh Limit Distance:** The max distance the nav mesh edge can be from the teleport destination to be considered valid. If a value of `0` is given then the nav mesh restriction will be ignored.
2082+
* **Nav Mesh Limit Distance:** The max distance the teleport destination can be outside the nav mesh to be considered valid. If a value of `0` is given then the nav mesh restrictions will be ignored.
20832083

20842084
### Class Events
20852085

0 commit comments

Comments
 (0)