Skip to content

Commit

Permalink
fix(Teleport): use the nav mesh check distance value in SamplePosition
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
thestonefox committed Nov 10, 2016
1 parent 356b09d commit 2e4616a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Assets/VRTK/Scripts/Abstractions/VRTK_WorldPointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ protected virtual bool ValidDestination(Transform target, Vector3 destinationPos
if (target)
{
NavMeshHit hit;
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, 0.1f, NavMesh.AllAreas);
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, navMeshCheckDistance, NavMesh.AllAreas);
}
if (navMeshCheckDistance == 0f)
{
Expand Down
4 changes: 2 additions & 2 deletions Assets/VRTK/Scripts/VRTK_BasicTeleport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class VRTK_BasicTeleport : MonoBehaviour
public string ignoreTargetWithTagOrClass;
[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.")]
public VRTK_TagOrScriptPolicyList targetTagOrScriptListPolicy;
[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.")]
[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.")]
public float navMeshLimitDistance = 0f;

/// <summary>
Expand Down Expand Up @@ -144,7 +144,7 @@ protected virtual bool ValidLocation(Transform target, Vector3 destinationPositi
if (target)
{
NavMeshHit hit;
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, 0.1f, NavMesh.AllAreas);
validNavMeshLocation = NavMesh.SamplePosition(destinationPosition, out hit, navMeshLimitDistance, NavMesh.AllAreas);
}
if (navMeshLimitDistance == 0f)
{
Expand Down
2 changes: 1 addition & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ The Basic Teleport script is attached to the `[CameraRig]` prefab.
* **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.
* **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.
* **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.
* **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.
* **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.

### Class Events

Expand Down

0 comments on commit 2e4616a

Please sign in to comment.