Few Questions :)

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Few Questions :)

Post by Tony Li »

If you can specify the GameObject that contains your script (or Set Active On Dialogue Event component) as the conversation's actor or conversant, it will receive the OnConversationStart/OnConversationEnd script messages. For example, if you're using a Conversation Trigger, assign the GameObject to its Actor or Conversant field. If you're calling DialogueManager.StartConversation() in a script, pass the transform of the GameObject.

NPCs, for example, often use components like Set Active On Dialogue Event to turn off gameplay AI during conversations.
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Few Questions :)

Post by HawkX »

**** man im sorry i really dont get that last part... i feel dumb when that happens... but considering i have only been coding for about a year
(been cinematic designer and video editor for about 12 years but never touched code before last year march)

I think this is the part i'd need help with as i am not using the triggers...
If you're calling DialogueManager.StartConversation() in a script, pass the transform of the GameObject.
I have 2 "relevant" scripts in my game scene, my GameManager which runs everything and calls StartConversation(string)... and the new one i made and named "UT_OnConvStart" which contains the code i pasted on page 1...
now I added :

Code: Select all

public void OnConversationStart (Transform scriptGM)
but I have no clue how to "pass" anything to it... since I am not the one actually calling it to execute it and it should be done automatically...

I keep re-re-reading what you wrote trying to make sense of it...
I think a better question might actually be :
How would I go to specify the Gameobject that contains that "Set Active on Dialogue" Component as the Dialogue Actor?

Again, I apologize for taking up so much of your time... Thank you again for helping out!! It really is greatly appreciated! :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Few Questions :)

Post by Tony Li »

Hi,

No worries! I have a feeling we'll get to the bottom of it soon.

You wrote that you're starting your conversation from a script, using code like:

Code: Select all

DialogueManager.StartConversation(stringVar); 
The DialogueManager.StartConversation method has variations that accept the transforms of GameObjects for the actor and/or conversant. So you could do something like this (just an example):

Code: Select all

var gm = GameObject.Find("Game Manager");
DialogueManager.StartConversation(stringVar, gm.transform);
Assuming the scene has a GameObject named "Game Manager", it will be designated as the conversation's actor. This means it will receive OnConversationStart and OnConversationEnd events.
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Few Questions :)

Post by HawkX »

I did mostly as you suggested... instead of using "find" in my GameManagerScript i created a public GameObject gm;
I then dragged the GameManager(GameObject) into its gm slot in the inspector.

here is the full function i use when calling the dialogues :

Code: Select all

	void StartConversation ()
	{
		if (DialogueManager.MasterDatabase.GetConversation (GV.stringCurrentFightLocation + intFightPhase.ToString()) != null)
		{
			DialogueManager.StartConversation (GV.stringCurrentFightLocation + intFightPhase.ToString(), gm.transform);
		}
	}
the check != null works... no warning... every conversations in the project also works when intended... and as you see, i send "gm.transform" to the DialogueManager when starting a conversation...

I tried with both the "Set active on dialogue event" as well as my own super mini script (NOT at the same time obviously)

Here is a copy of my own mini script (also attached to GameManager(GameObject)) :

Code: Select all

	public GameObject go1; //both stuff that needs to be toggled off
	public GameObject go2;

	public void OnConversationStart (Transform gm)
	{
		go1.SetActive(false);
		go2.SetActive(false);
	}

	public void OnConversationEnd (Transform gm)
	{
		go1.SetActive(true);
		go2.SetActive(true);
	}
Yet nothing works... nothing toggle off during the conversation...

Again, sorry for making you work so hard for me... but know that it is GREATLY appreciated! :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Few Questions :)

Post by Tony Li »

Set the Dialogue Manager's Debug Level to Info. Then play through to start the conversation. In the Console window, along with a lot of other lines, you should see a line similar to:

Code: Select all

Dialogue System: Starting conversation 'title' with actor=ABC and conversant=XYZ
where title is the title of the conversation, ABC is the actor's transform, and XYZ is the conversant's transform.

Make sure your GameManager GameObject is actually listed as the actor or conversant.

It may also help to add a Conversation Logger component to your GameManager. If the GameManager is receiving the conversation events, it should log colored lines to the Console.

Also please feel free to send an example project to tony (at) pixelcrushers.com and let me know what version of Unity to use. I'll be happy to take a look.
User avatar
HawkX
Posts: 147
Joined: Mon Feb 27, 2017 1:50 pm
Location: Quebec
Contact:

Re: Few Questions :)

Post by HawkX »

Here is the info line when the conversation "hotel0" starts :

Dialogue System: Starting conversation 'hotel0', actor=GameManager (UnityEngine.Transform), conversant=.
UnityEngine.Debug:Log(Object, Object)

I also added the logger to the GameManager, and all the text lines appeared in Red so that works.

I'd like to send the project over, however, sending a 2GB rar over email might be a bit overkill.. i'd have to strip the project of pretty much everything to be able to achieve that and that would take a while... (i could probably upload the rar to my googledrive and send you the link at your email address if we cannot make it work at all)

EDIT : I added the "set component enabled" to my game manager just to do some tests... then i added the image/button component of a few items (3 out of the 40 something i'd actually need to put in) and it worked! they were toggled off during the conversation and came back on... so i guess i could always make them ALL in that module to disable all of them individually instead of toggling the empty gameobject that holds them all itself... its really not efficient however ;) -- and i tried right away again with the other one "set active"... and it still refuses to accept the gameobject themselves... -- Finally, just for fun, i tried using the set component enabled with the empty game objects... got the following warning : "Dialogue System: Don't know how to enable/disable BlackFrame.RectTransform"

OK i dont know what to think now... I went back into my own tiny script and added a manual "Debug.Log("entered conv")" as well as another one for the OnConversationEnd and both of them got triggered... yet the gameobject are not getting set to go1.SetActive(false); -- I double checked the link were pointing to the correct game object... and this is something i use all the time (gameobject.setactive(false)/true)... why does it not work there!?

ALRIGHT i figured it out... DAMN im stupid... so sorry... it was actually my fault... as i toggle on and off most of my controls, there were checks in place that would toggle them right back on after they were shut down... so now i need to make a global boolean "inCutscene" and make sure i dont touch those gameobject setactive while a cutscene is playing! I apologize for taking so much of your time!

FINAL EDIT : HELL YES!!!! :D all is working perfectly now!!! THANKS for your patience in helping me out!! :)
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Few Questions :)

Post by Tony Li »

Awesome! I'm glad it's working now! When I saw your pre-edit reply, I suspected another script might be re-activating the GameObject -- because I've done the same thing myself. Just another day in the the life of a software developer, eh? :-)
Post Reply