From 2747c1e0afe05bd6b22bb5d8593666ad5c8de14c Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Fri, 4 Feb 2022 17:43:37 +0100 Subject: [PATCH] Added check on empty objects --- Runtime/HumanoidFree/Scripts/HumanoidControl.cs | 2 ++ Runtime/Sites/Scripts/HumanoidInterface.cs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Runtime/HumanoidFree/Scripts/HumanoidControl.cs b/Runtime/HumanoidFree/Scripts/HumanoidControl.cs index 54f4c9c..08d644b 100644 --- a/Runtime/HumanoidFree/Scripts/HumanoidControl.cs +++ b/Runtime/HumanoidFree/Scripts/HumanoidControl.cs @@ -386,6 +386,8 @@ namespace Passer.Humanoid { } public void LocalChangeAvatar(GameObject avatarPrefab) { + if (avatarPrefab == null) + return; Animator animator = avatarPrefab.GetComponent(); if (animator == null || animator.avatar == null || !animator.avatar.isValid) { diff --git a/Runtime/Sites/Scripts/HumanoidInterface.cs b/Runtime/Sites/Scripts/HumanoidInterface.cs index 75ea030..bac43c1 100644 --- a/Runtime/Sites/Scripts/HumanoidInterface.cs +++ b/Runtime/Sites/Scripts/HumanoidInterface.cs @@ -112,6 +112,9 @@ namespace Passer.Humanoid { /// The GameObject of the Possession to add /// This does nothing if the gamObject is not a Possession public void TryAddToPossessions(GameObject gameObject) { + if (gameObject == null) + return; + Possessable possession = gameObject.GetComponent(); if (possession == null) return;