Skip to content

Commit 344e3d1

Browse files
committed
Fixed a potential null ref in SolverBodyLock.cs
Fixes #2073
1 parent bb32475 commit 344e3d1

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

Assets/HoloToolkit/Utilities/Scripts/Solvers/SolverBodyLock.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
//
21
// Copyright (c) Microsoft Corporation. All rights reserved.
32
// Licensed under the MIT License. See LICENSE in the project root for license information.
4-
//
3+
54
using UnityEngine;
6-
using System.Collections;
7-
using System.Collections.Generic;
85

96
namespace HoloToolkit.Unity
107
{
118
/// <summary>
129
/// SolverBodyLock provides a solver that follows the TrackedObject/TargetTransform. Adjusting "LerpTime"
13-
/// properties changes how quickly the object moves to the TracketObject/TargetTransform's position.
10+
/// properties changes how quickly the object moves to the TrackedObject/TargetTransform's position.
1411
/// </summary>
1512
public class SolverBodyLock : Solver
1613
{
@@ -28,22 +25,20 @@ public enum OrientationReference
2825
}
2926
#endregion
3027

31-
3228
#region public members
3329
[Tooltip("The desired orientation of this object. Default sets the object to face the TrackedObject/TargetTransform. CameraFacing sets the object to always face the user.")]
3430
public OrientationReference Orientation = OrientationReference.Default;
3531
[Tooltip("XYZ offset for this object in relation to the TrackedObject/TargetTransform")]
3632
public Vector3 offset;
3733
[Tooltip("RotationTether snaps the object to be in front of TrackedObject regardless of the object's local rotation.")]
3834
public bool RotationTether = false;
39-
[Tooltip("TetherAngleSteps is the divison of steps this object can tether to. Higher the number, the more snapple steps.")]
35+
[Tooltip("TetherAngleSteps is the division of steps this object can tether to. Higher the number, the more snapple steps.")]
4036
[Range(4, 12)]
4137
public int TetherAngleSteps = 6;
4238
#endregion
4339

4440
public override void SolverUpdate()
4541
{
46-
Vector3 desiredPos = base.solverHandler.TransformTarget != null ? base.solverHandler.TransformTarget.position + offset : Vector3.zero;
4742
Quaternion desiredRot = Quaternion.identity;
4843

4944
if (RotationTether)
@@ -62,10 +57,10 @@ public override void SolverUpdate()
6257
desiredRot = Quaternion.Euler(0f, tetherYRotation, 0f);
6358
}
6459

65-
desiredPos = solverHandler.TransformTarget.position + (desiredRot * offset);
60+
Vector3 desiredPos = solverHandler.TransformTarget != null ? solverHandler.TransformTarget.position + (desiredRot * offset) : Vector3.zero;
6661

67-
this.GoalPosition = desiredPos;
68-
this.GoalRotation = desiredRot;
62+
GoalPosition = desiredPos;
63+
GoalRotation = desiredRot;
6964

7065
UpdateWorkingPosToGoal();
7166
UpdateWorkingRotToGoal();

0 commit comments

Comments
 (0)