Interactable fails with MoveTowards

ChristianWiele

Active member
Hi,

I have a strange situation with one of my interactables. I am using the Dialogue System integration to start a conversation with my NPCs. The NPC has a MoveTowards location to start the conversation in the right position. The interactable is correctly identified, and the character starts the MoveTowards movement. When arriving at the location the system tries to start the interact ability. But then two things happen

1.) The CanStartAbility on the interact ability fails and sets the m_interactable variable to null (line numbers shifted due to debug statements)
Code:
Opsive.UltimateCharacterController.Character.Abilities.Interact:CanStartAbility () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Interact.cs:101)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:UpdateAbilities (Opsive.UltimateCharacterController.Character.Abilities.Ability[]) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:802)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:OnImmediateTransformChange (bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:2313)
Opsive.Shared.Events.InvokableAction`1<bool>:Invoke (bool)
Opsive.Shared.Events.EventHandler:ExecuteEvent<bool> (object,string,bool)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion:SetPositionAndRotation (UnityEngine.Vector3,UnityEngine.Quaternion,bool,bool) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:2009)
Opsive.UltimateCharacterController.Character.Abilities.MoveTowards:MoveTimeout () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/MoveTowards.cs:440)
Opsive.Shared.Game.ScheduledEvent:Invoke ()
Opsive.Shared.Game.SchedulerBase:Invoke (Opsive.Shared.Game.ScheduledEventBase,int)
Opsive.Shared.Game.SchedulerBase:Update ()

2.) The interact ablity is started and throws an exception because the m_interactable is null (line numbers shifted due to debug statements)
Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Character.Abilities.Interact.AbilityStarted () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Interact.cs:196)
Opsive.UltimateCharacterController.Character.Abilities.Ability.StartAbility (System.Int32 index) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Ability.cs:475)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean ignorePriority, System.Boolean ignoreCanStartCheck) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:1213)
Opsive.UltimateCharacterController.Character.Abilities.MoveTowards.MoveTimeout () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/MoveTowards.cs:442)
Opsive.Shared.Game.ScheduledEvent.Invoke () (at <6b6b48297d4f49e9ba244a49e70e6e92>:0)
Opsive.Shared.Game.SchedulerBase.Invoke (Opsive.Shared.Game.ScheduledEventBase scheduledEvent, System.Int32 index) (at <6b6b48297d4f49e9ba244a49e70e6e92>:0)
Opsive.Shared.Game.SchedulerBase.Update () (at <6b6b48297d4f49e9ba244a49e70e6e92>:0)

Seems that the problem results from teleporting to the location, as the SetPositionAndRotation (line 440 in MoveTowards) call triggers an unnecessary CanStartAbility call which for some reason fails.

Thanks, Christian
 
I think, I found the issue. The MoveTowards location was slightly pointing past the NPC, so when the character was teleported to the location, the CanStartAbility failed to detect the NPC / interactable. But the question is more, why at all another CanStartAbility check is performed, although the ability is started anyway afterwards (line 442 in MoveTowards).
 
Top