Page 1 of 1

Camera Angles with Code

Posted: Thu Mar 02, 2017 3:31 pm
by HawkX
Hi again! :)

Before I ask my question, just wanted to give a quick update on my first topic, if anyone ever asks how to get rid of the first few frames when we see the frame of the UI... the best solution is to reduce the "hide" animation from 30 frames to about 5... that way its 100% invisible on startup but you still retain the anims...

Today, I'm trying to manually change camera angles in my dialogues...

As you might remember, I am using :

Code: Select all

DialogueManager.StartConversation (stringC, goTransform);
to call up my dialogues...

I was wondering if there was a way to also specify a camera angle that way...

I already created my own "Camera Angle" prefab (which has 2 settings, standard, and closeup)

I'd like to be able to switch (or animate) to closeup (like you did in your sequencer demo)... but without changing how I start the conversations...

Is it something that is possible? or should I rethink how I do thing? :)

Again, thanks a lot for your time and assistance!

Re: Camera Angles with Code

Posted: Thu Mar 02, 2017 4:00 pm
by Tony Li
When you write your conversation, what about setting the START node's Sequence to something like:

Code: Select all

Camera(closeup,,1)
The unspecified middle parameter defaults to the speaker, which is goTransform in this case. So it will move the camera from its current position to a closeup of goTransform over 1 second.

There are a lot of options for camera control. If the suggestion above doesn't help, let me know. I have a plenty more. :-)

Here are some random notes:
  • The keywords 'speaker' and 'listener' correspond to the GameObjects associated with the characters speaking the current line and being spoken to. (See How GameObjects Are Associated With Conversations)
  • If your camera angle "prefab" is actually a GameObject in the scene, you can add new camera angles (i.e., child GameObjects) at runtime.
  • You can also specify absolute scene GameObject names in the Camera() sequencer command. So you can position an empty GameObject at an exact position in the scene and use Camera() to put the camera there.
  • Camera() also accepts keywords 'original' (the camera's position at the start of the conversation) and 'default'. You can specify a character's default camera angle by adding a Default Camera Angle component.

Re: Camera Angles with Code

Posted: Fri Mar 03, 2017 11:20 am
by HawkX
Hi,

once again, thank you for your time! :)

Here is the error I got when adding your line to the Sequence of the Start of a conversation :

Code: Select all

Dialogue System: Sequencer: Camera subject '' wasn't found.
UnityEngine.Debug:LogWarning(Object)
PixelCrushers.DialogueSystem.SequencerCommands.SequencerCommandCamera:Start()
The camera DID move when i started the cutscene, but instead of a zoomin, it did a zoomout+travelling... but at least i got something!! :)

Considering my game is a 2D game which exists only in UI-Canvas, its not the same as when you have 3d character that actually "exists" in the world that speak to each other...

But overall, that is pretty much all i needed to know! ;) I'll keep messing around with it and i'll 100% find out and make it works, so no worries! :)

Thanks again!

Re: Camera Angles with Code

Posted: Fri Mar 03, 2017 11:39 am
by Tony Li
Hi,

If you're using an orthographic camera, you may want to use Zoom2D() instead of Camera().

In either case, this means it's not finding the 'speaker' of the line. Inspect the START node, and look up who is assigned as its Actor. It's probably set to Player.

If you're starting the conversation with this line:

Code: Select all

DialogueManager.StartConversation(stringVar, goTransform);
then goTransform should be used as the transform for Player. So it should try to use goTransform as the 'speaker'.

You may find it helpful to temporarily set the Dialogue Manager's Debug Level to Info. Look for a line like this:

Code: Select all

Dialogue System: Starting conversation 'ABC' with actor=XXX and conversant=
If that doesn't help, you can always specify a GameObject to zoom on:

Code: Select all

Zoom2D(someObjectInScene)

Re: Camera Angles with Code

Posted: Fri Mar 03, 2017 11:44 am
by HawkX
hahah... WOW you are fast!!!

I was simply coming back to edit my post and write i figured it out (as i said i would) ;)

Its a hack (somewhat)... but to make sure the anim worked, i did the following line :

Code: Select all

Camera(CloseupOnFace,Dialogue Manager,1)
i dont really care that it "thinks" its zooming on something... i just needed a gameobject at 0,0,0 to zoom on...

and the camera is NOT an orthographic since i use worldspace for some particle fx... (although its good to know for the future)...

I think the reason it did not want to use "goTransform" as the speaker is that actual game object is only on my 3rd scene that gets loaded... and the dialogue manager is on the very first one... thats why it got the error when starting the game...

I will most likely be back in a week or two with more questions! :P hehe... thanks again!! have a great day!!

Re: Camera Angles with Code

Posted: Fri Mar 03, 2017 11:49 am
by Tony Li
Happy to help! Have a good weekend!