Works fine but creating errors for me (see video)

Hi guys,

Everything Sam showed works fine. I added serialized voice clips to each node with a getter and that worked fine. The problem I’m having is with the Speaker’s avatars that I added. the avatars show up perfectly however I keep receiving this persistent parent error when it instantiates the avatar with a SetParent() to the DialogueUI. Any thoughts as to why this could be happening? The video is below and I’ll post the code beneath that.

Persistent parent error

            if (newAvatar != null)
            {
                Destroy(newAvatar.gameObject);
            }
            avatar = playerConversant.GetSpeakerAvatar();
            if (avatar != null)
            {
                newAvatar = Instantiate(avatar, avatar.transform) as GameObject;
                newAvatar.transform.SetParent(transform, false);


            }

Also there’s another issue which I’m trying to fix in the video below. tl;dw, essentially the UI only activates if it is marked as active before running the game and the game itself disables it before the first frame otherwise it throws a null reference. is there anyway to refactor it so that even if the ui was disabled before play, it would still add an event listener for the convo to start?

null reference

Thanks

Okay so the first error is fixed. it was pointed out to me that the second argument of instantiate “avatar.transform” was assigning itself as a parent instead of what I thought was assigning its position and rotation. So I removed that argument and it now works.

Just the null reference left

Put the script that listens for dialogue starting on a GameObject that is not disabled, and then put the UI on a GameObject under it. This UI under the parent GameObject is the one that you want to enable and disable.

Yeah I think that might be the only way to prevent any possible errors. Thanks Brian

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms