(Solved) Streamlined way to set Camera Angle by Gameobject?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Gemini
Posts: 6
Joined: Sat Nov 30, 2019 12:58 am

(Solved) Streamlined way to set Camera Angle by Gameobject?

Post by Gemini »

Feeling a little silly posting here already, but had figured if I can figure out how to streamline this now rather than later I'll be saving myself future headaches.

So I've been following along with the manual and the video tutorials -and I've learned that most of my models are a bit shorter than what the Closeup Camera Angle is able to capture. I've been using the free asset 'Unity-chan' as a testing model for the player and NPCs because it's roughly the same dimensions of my own models. I was able to get the 'model is too short for the camera closeup' issue sorted out thanks to an unlisted tutorial vid (the one with the Trooper and the Rat, linked through this forum) which was really useful.

So now I have made 3 custom close ups:

-CloseupChild
-CloseupTeen
-CloseupAdult

They're all exactly the same as default closeup aside from one being much lower, one being a bit lower and one the same height as default closeup.

So I'm now able to go into the conversation manager and click on each node of dialogue and manually set the sequencer box with the code: "Camera(CloseupTeen,speaker,1)" with the "Closeup___" name depending if the model's height is a child, teen, or adult.

This works, but now I'm a bit worried when I picture the amount of nodes this is going to add up to. Is there any way for me to have the dialogue node just check the gameobject properties for what camera angle to use?
I mean, aside from rare instances, I always plan for the camera angle to be closeup, so it just needs each gameobject to tell it if it's closeup with child-height, teen-height or adult height, right?

I added on a "Default Camera Angle (Script)" component to the gameobject NPCs, hoping I could change the Default Camera Angle to my custom CameraAngle Folder thing, but it seems to be stuck and grayed out as "DefaultCameraAngle" -I don't seem to be able to click and drag my altered "Special Camera Angles" folder thing onto it...
I'm not even sure if that's the right way to go about this so I thought I'd come here and ask.

So there we are, long story short, is there any way I can set the camera angle by gameobject/actor properties rather than typing it manually into each node sequencer box?

Thank you for your time!
Last edited by Gemini on Sat Dec 07, 2019 11:29 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Streamlined way to set Camera Angle by Gameobject?

Post by Tony Li »

Hi,

I'll zip through the steps, some of which you may have already done, to make sure we haven't missed anything:

1. Save your "Special Camera Angles" as a prefab. It should be very similar to the "Default Camera Angles" prefab located in Plugins / Pixel Crushers / Dialogue System / Resources. You don't need to add any scripts to your Special Camera Angles prefab. Then assign the Special Camera Angles prefab to the Dialogue Manager's Camera & Cutscene Settings > Camera Angles field.

2. Add a Default Camera Angle component to each character. Set the Camera Angle field. For example, your Unity-Chan character should probably set Camera Angle to CloseupTeen.

3. Set the Dialogue Manager's Camera & Cutscene Settings > Default Sequence to something like:

Code: Select all

Camera(default); 
Delay({{end}})
4. Leave the Sequence fields of your dialogue entry nodes blank, or include "{{default}}" to include the Dialogue Manager's Default Sequence, such as:

Code: Select all

{{default}}; AudioWait(hello)
If the Sequence field is blank, it will use the Dialogue Manager's Default Sequence.
User avatar
Gemini
Posts: 6
Joined: Sat Nov 30, 2019 12:58 am

Re: Streamlined way to set Camera Angle by Gameobject?

Post by Gemini »

Started a new project, and yeah, everything works perfectly!
(Technically I do also get a weird message in the error console saying: "Dialogue System: Unrecognized shortcut {{end}} " and "Dialogue System: Syntax error 'Can't convert {{end}} to a number' at column 59 row 1 parsing: Camera(default); required Camera(default,listener)@{{end}} UnityEngine.Debug:LogWarning(Object)"
-but it doesn't seem like it's breaking anything so I'll just ignore it.)

Anyway, the only one that seems to ignore this is the player character (3rd person controller ala invector shooter asset, using same Unity-chan model. Got it to stay still by checking the 'pause the game during convo' box -I don't believe that's causing this issue however, just mentioning it).
Despite me putting the same "Dialogue Actor (Script)" Component and "Default Camera Angle (Script)" Component that is used to get the NPCs working with the automatic camera angle, it just never looks over at the player.

However! I can trigger the camera angle closeup if I manually go into the node of that player's dialogue and at the sequencer field put: "Camera(CloseupTeen,speaker,1)" the camera does pan over to the player's face -but only AFTER you select one of the player's choice options.
Some other details:
-If the player response was the last node in the convo, then after choosing it the camera starts to pan over to the player but then the conversation ends and everything goes back to before the convo.
-If there's another player response node after it, then the camera actually stays on the player during the 2nd choice node.

So yeah, to summarize, it doesn't seem like I'm able to set an automatic default camera angle for the player, only manually by adding it to the node, but even then it's like it's stuck waiting until you select a choice response before moving to the player's face?

(And also thank you for all the help so far!)
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Streamlined way to set Camera Angle by Gameobject?

Post by Tony Li »

Hi,

Those errors ("Dialogue System: Unrecognized shortcut {{end}}" etc.) definitely shouldn't be happening.

If you play the Dialogue System's DemoScene1, does it also report that error?

It's preventing this sequence from running correctly:

Code: Select all

Camera(default); required Camera(default,listener)@{{end}}
That sequence has two commands.
The first command cuts the camera to the speaker's (NPC's) default camera angle.
The second command runs after a duration determined by the text length. It cuts the camera to the listener's (player's) default camera angle.

Note that if you were to tick the Dialogue Manager's Subtitle Settings > Show PC Subtitles During Line and untick Skip PC Subtitle After Response Menu, then the conversation would also show the player's lines as subtitles. In this case, the sequence would first cut to the player's default camera angle because the player would be the speaker. After a duration based on the text length, it would cut to the NPC's default camera angle.
User avatar
Gemini
Posts: 6
Joined: Sat Nov 30, 2019 12:58 am

Re: Streamlined way to set Camera Angle by Gameobject?

Post by Gemini »

It doesn't report that error when I enter the demo scene and interact with the trooper and Terminal, so it's probably something I did wrong with my scene I suppose. Doh. Update: Actually after closing and reopening the unity project they no longer appear when I play the scene or conversation. Hooray? I'll take it haha.

The code you provided "Camera(default); required Camera(default,listener)@{{end}}"
works 100% though it would seem that I would have to go to each node preceding a player choice/regular player text node and add that to the sequencer in order to get the camera to pan to the player's face before the choice starts. This would be pretty doable for the game.

Ticking and unticking those 2 boxes in the subtitle section works for having the camera show the player's face for the text, though it still came only after the player choices appear over the npc's face. (however, if I use it in conjunction with that code from above it does actually pan to the player's face just in time for their choices to appear! It works!)

The only problem is, strangely, now everytime the camera pans over to the player, when the player text finishes, it waits a second then immediately flips back over to the npc, even though it's still the player's text overhead, and that npc has no further lines of dialogue in the conversation. (this happens everytime the player has a response, not just when that aforementioned code is used in the nodes).

I attached a quick 40 second clip of this happening, just in case I'm not describing it well:
https://upload-video.net/a21065brj12-noau
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Streamlined way to set Camera Angle by Gameobject?

Post by Tony Li »

Hi,

Okay, we're making progress! I didn't want to flood you with details right away, but I should've mentioned the next step. Try changing the Dialogue Manager's Default Sequence to:

Code: Select all

Camera(default); Delay({{end}})
Leave the Default Player Sequence blank. If it's blank, it will use the Default Sequence.

Set the Default Response Menu Sequence to:

Code: Select all

Camera(default,listener)
The Default Response Menu Sequence runs at the end of the dialogue entry node (i.e., whoever just spoke) if the next step is a player response menu. The Default Response Menu Sequence above will cut to the default camera angle of the person being spoken to (i.e., the player).
User avatar
Gemini
Posts: 6
Joined: Sat Nov 30, 2019 12:58 am

Re: Streamlined way to set Camera Angle by Gameobject?

Post by Gemini »

The edits to those fields really did the trick, though the camera was still a teensy bit off, however, I made the small change of:
"Camera(default,listener)"
to
"Camera(default,Player)"
in the default response Menu Sequence, and now everything works a charm!

Looks like that's pretty much everything I was wanting to set up here, camera-wise.

I'll try to record/write a little tutorial for custom camera-angles and automating them based on the components of the gameobject, that way future me doesn't forget and maybe it would be helpful for other newbies trying to puzzle out the same thing?
Maybe I'll do a separate tutorial for the setup of making the camera always face the Player for dialogue choices as well.
Though that may take a while with the holidays being so close :P

It'll also probably be a while before I bug the forum again. I'll be studying up on playing animations during dialogue and freezing the 3rd person controller.

Anyway, I do really want to thank you for all the incredibly quick responses! Never would have figured it out without you!
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: Streamlined way to set Camera Angle by Gameobject?

Post by Tony Li »

Glad to help!

If you do end up recording those tutorials, I'll be happy to link to them.
Post Reply