diff --git a/Packages/PlayerControl/Runtime/PlayerController.cs b/Packages/PlayerControl/Runtime/PlayerController.cs index e660c0c..ffdc614 100644 --- a/Packages/PlayerControl/Runtime/PlayerController.cs +++ b/Packages/PlayerControl/Runtime/PlayerController.cs @@ -129,10 +129,46 @@ protected Quaternion WorldRotation protected virtual void Start() { - transform = GetComponent(); - constants = new AnimHashConstants(); - PlayerInput.onActionTriggered += context => OnActionTriggered(context); - JumpControl.OnJump.AddListener(OnJump); + try + { + transform = GetComponent(); + } + catch (Exception e) + { + Exception ee = new Exception("Failed to get the ITransform component.", e); + Debug.LogException(ee); + throw; + } + try + { + constants = new AnimHashConstants(); + } + catch (Exception e) + { + Exception ee = new Exception("Failed to create the AnimHashConstants.", e); + Debug.LogException(ee); + throw; + } + try + { + PlayerInput.onActionTriggered += context => OnActionTriggered(context); + } + catch (Exception e) + { + Exception ee = new Exception("Failed to set the action triggered event.", e); + Debug.LogException(ee); + throw; + } + try + { + JumpControl.OnJump.AddListener(OnJump); + } + catch (Exception e) + { + Exception ee = new Exception("Failed to set the jump event.", e); + Debug.LogException(ee); + throw; + } } protected virtual void Update() @@ -141,6 +177,12 @@ protected virtual void Update() { Animator.SetFloat(constants.Speed, CurrentSpeed); } + catch (NullReferenceException e) when (constants == null) + { + Exception ee = new Exception("Failed to set the speed parameter in constants.", e); + Debug.LogException(ee); + throw; + } catch (Exception e) { Exception ee = new Exception("Failed to set the speed parameter.", e);