Added check on empty objects

This commit is contained in:
Pascal Serrarens 2022-02-04 17:43:37 +01:00
parent 512c035917
commit 2747c1e0af
2 changed files with 5 additions and 0 deletions

View File

@ -386,6 +386,8 @@ namespace Passer.Humanoid {
} }
public void LocalChangeAvatar(GameObject avatarPrefab) { public void LocalChangeAvatar(GameObject avatarPrefab) {
if (avatarPrefab == null)
return;
Animator animator = avatarPrefab.GetComponent<Animator>(); Animator animator = avatarPrefab.GetComponent<Animator>();
if (animator == null || animator.avatar == null || !animator.avatar.isValid) { if (animator == null || animator.avatar == null || !animator.avatar.isValid) {

View File

@ -112,6 +112,9 @@ namespace Passer.Humanoid {
/// <param name="gameObject">The GameObject of the Possession to add</param> /// <param name="gameObject">The GameObject of the Possession to add</param>
/// This does nothing if the gamObject is not a Possession /// This does nothing if the gamObject is not a Possession
public void TryAddToPossessions(GameObject gameObject) { public void TryAddToPossessions(GameObject gameObject) {
if (gameObject == null)
return;
Possessable possession = gameObject.GetComponent<Possessable>(); Possessable possession = gameObject.GetComponent<Possessable>();
if (possession == null) if (possession == null)
return; return;