File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Packages/webxr-interactions Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
7
7
## [ Unreleased]
8
8
9
+ ### Fixed
10
+ - Null reference errors when destroying contacted interactables.
11
+
9
12
## [ 0.14.0] - 2021-12-26
10
13
### Added
11
14
- Support for AR headsets in SceneHitTest.
Original file line number Diff line number Diff line change @@ -528,9 +528,15 @@ private Rigidbody GetNearestRigidBody()
528
528
Rigidbody nearestRigidBody = null ;
529
529
float minDistance = float . MaxValue ;
530
530
float distance = 0.0f ;
531
+ bool removeNulls = false ;
531
532
532
533
foreach ( Rigidbody contactBody in contactRigidBodies )
533
534
{
535
+ if ( contactBody == null )
536
+ {
537
+ removeNulls = true ;
538
+ continue ;
539
+ }
534
540
distance = ( contactBody . gameObject . transform . position - transform . position ) . sqrMagnitude ;
535
541
536
542
if ( distance < minDistance )
@@ -540,6 +546,11 @@ private Rigidbody GetNearestRigidBody()
540
546
}
541
547
}
542
548
549
+ if ( removeNulls )
550
+ {
551
+ contactRigidBodies . RemoveAll ( x => x == null ) ;
552
+ }
553
+
543
554
return nearestRigidBody ;
544
555
}
545
556
}
You can’t perform that action at this time.
0 commit comments