Receive error when OnConversationStart(Transform) is called.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jgifford
Posts: 5
Joined: Wed Mar 15, 2023 2:43 pm

Receive error when OnConversationStart(Transform) is called.

Post by jgifford »

The below error is generated when the OnConversationStart(Transform) event is invoked in the DialogueSystemEvents component. This prevents the event from actually running the method I need it to.

Unity Version: 2022.2.10
OS: Windows 10

Code: Select all

ArgumentException: Object of type 'UnityEngine.Object' cannot be converted to type 'UnityEngine.Transform'.
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: Receive error when OnConversationStart(Transform) is called.

Post by Tony Li »

Hi,

Make sure you're using the current version of the Dialogue System.

Then check what's actually assigned to the OnConversationStart() UnityEvent. Something may be assigned incorrectly. If this doesn't help, please post a screenshot of the OnConversationStart() UnityEvent of your Dialogue System Events inspector.
jgifford
Posts: 5
Joined: Wed Mar 15, 2023 2:43 pm

Re: Receive error when OnConversationStart(Transform) is called.

Post by jgifford »

I am using version 2.2.34

The forum won't let me post the full stack trace unfortunately. It says "Forbidden. You sent forms too often. Please wait a few minutes. Contains contacts." But double clicking it in Unity opens ConversationModel.cs, line 214 in the InformParticipants method.

What I am trying to do is call a function in my PlayerController class that locks the camera's view on the actor when the conversation starts. This error is thrown even with a blank function though.

Code: Select all

        public void OnDialogueStart(Transform actor)
        {
            DialogueLookTarget lookTarget = actor.GetComponentInChildren<DialogueLookTarget>();
            look.SmoothLookAt(lookTarget == null ? actor.position : lookTarget.position, dialogueSmoothLookAtTime);

            SetState(State.Dialogue);
        }
Screenshot 2023-03-16 190112.png
Screenshot 2023-03-16 190112.png (34.69 KiB) Viewed 187 times
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: Receive error when OnConversationStart(Transform) is called.

Post by Tony Li »

Hi,

Try assigning a Transform to the first UnityEvent element (PlayerController.OnDialogueStart) or -- probably better yet -- select the Dynamic version of PlayerController.OnDialogueStart from the dropdown menu. This will make it pass the actual transform that was sent with the OnConversationStart message.
jgifford
Posts: 5
Joined: Wed Mar 15, 2023 2:43 pm

Re: Receive error when OnConversationStart(Transform) is called.

Post by jgifford »

Well that is embarrassing... I had selected the static version of the method in the dropdown instead of the dynamic one.

Thank you for the help!
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: Receive error when OnConversationStart(Transform) is called.

Post by Tony Li »

No worries -- glad I could help!
Post Reply