Page 1 of 1

Stopping Camera Angles?

Posted: Tue May 31, 2016 11:59 pm
by mellopillow
Hi, I recently bought the Dialogue System and I'm using it for a Unity3d student project. I have a few questions:

Whenever I go interact with the NPC using the proximity selector script or any other selector script, the camera angle zooms out and stays in that angle even when the conversation has ended. Is there any way to fix this, or better yet, have it not use a camera angle altogether?

I tried looking at many tutorials and so far haven't seen anything that can help yet. Another thing I would like to know is how can one trigger an event when a player chooses an option from a dialogue, specifically setting a float variable from a different script to a different number.

Currently, the player character game object I have has a camera child and uses a smooth camera follow. However, the movement is done using a custom script and does not have mouse control that moves the camera yet (still learning how to!). If there are any other specific things you would like to know to better help me, feel free to ask! :D

Thank you

Re: Stopping Camera Angles?

Posted: Wed Jun 01, 2016 12:30 am
by Tony Li
Hi,

Thanks for buying the Dialogue System!
mellopillow wrote:Whenever I go interact with the NPC using the proximity selector script or any other selector script, the camera angle zooms out and stays in that angle even when the conversation has ended. Is there any way to fix this, or better yet, have it not use a camera angle altogether?
Set the Dialogue Manager's Display Settings > Camera Settings > Default Sequence to: Delay({{end}})
This will pause the subtitle for a duration proportional to the text length, without touching the camera.

If you end up using Camera() sequencer commands to control the camera during conversations at some point, you'll want to temporarily disable your smooth camera follow during the conversation to prevent it from fighting with the Dialogue System. Use the Set Component Enabled On Dialogue Event component to do this. You can read more about this in the How To Set Up The Player section. You can also use this component to temporarily prevent the player from moving around during conversations.
mellopillow wrote:Another thing I would like to know is how can one trigger an event when a player chooses an option from a dialogue, specifically setting a float variable from a different script to a different number.
Register a C# method with the Lua environment, and then use it in a dialogue entry node's Script field.

For example, say you have a script that keeps track of a value such as GPA:

Code: Select all

public class GradePointAverage : MonoBehaviour {
    public float gpa; //<--This is the player's current GPA.
} 
Add a method to change gpa, and a couple methods to register it with the Dialogue System:

Code: Select all

using PixelCrushers.DialogueSystem;

public class GradePointAverage : MonoBehaviour {
    public float gpa; //<--This is the player's current GPA.
    
    void OnEnable() {
        Lua.RegisterFunction("SetGPA", this, typeof(GradePointAverage).GetMethod("SetGPA"));
    }
        
    void OnDisable() {
        Lua.UnregisterFunction("SetGPA");
    }
        
    public void SetGPA(double value) { // Lua uses doubles.
        return gpa = (float) value;
    }    
}
Then use the "SetGPA" function in a dialogue entry node:
  • Dialogue Text: "Great job! You get an A+."
  • Script: SetGPA(4.0)
If you register Lua functions that return values, you can also use them in the Conditions field. For example, say you've registered a function GetGPA() that returns the current value of gpa:
  • Dialogue Text: "Would you like to join the Honors Program?"
  • Script: GetGPA() >= 3.5

Re: Stopping Camera Angles?

Posted: Wed Jun 01, 2016 2:05 am
by mellopillow
Thanks so much for the quick response! This helped quite a lot, although the camera problems were solved by putting the camera tag as MainCamera. The settings were already in those you specified in the response when it was having problems, but it was still helpful.

Thanks again for the Lua explanation and I'll be sure to ask if I have any other questions :)

Re: Stopping Camera Angles?

Posted: Wed Jun 01, 2016 10:12 am
by Tony Li
Sounds good. Happy to help! (Although in the end you fixed it yourself. ;) )