Camera Doesn't Return After Sequence

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bautistac
Posts: 14
Joined: Tue Jan 06, 2015 5:31 pm

Camera Doesn't Return After Sequence

Post by bautistac »

Hello again,



I am working with the sequencer to do cutscenes with camera angle changes. When I set the camera angle via conversation node sequence, it stays until the conversation ends. I want to move the camera back to the player on the next node but I can't find the command to do it.



I am also having camera issues after the sequence. I tried with my player cam and with a prefab cam. When I use the player cam, the scripts that I specified in the SetEnabledonDialogueEvent aren't being affected at all and I can move the camera during the angle change. Then the camera stays in this position after cutscene. With the prefab camera, my view disappears after cutscene.



I have all of the nodes set to NPC in my conversation. This was done to create narrator style messages.



Can anyone help?
User avatar
Tony Li
Posts: 20864
Joined: Thu Jul 18, 2013 1:27 pm

Camera Doesn't Return After Sequence

Post by Tony Li »

Hi,



To move the camera back to its original, pre-conversation position, pass the special keyword 'original' to the Camera() sequencer command. You could set the node's Sequence to this:

Camera(mySpecialAngle); required Camera(original)@{{end}}

When the node runs, Camera(mySpecialAngle) will immediately move the camera to "mySpecialAngle". At the very end of the node, it will move the camera back to its original position. The 'required' keyword tells the sequencer to run Camera(original) even if the player cancels the node before its time is up. This ensures that the camera ends up in the correct final position no matter what.



The top of this manual page has some notes about how the Dialogue System uses the sequencer camera. The highlights are:



1. If you leave Dialogue Manager > Sequencer Camera unassigned, it will automatically borrow the first camera in the scene that's tagged "MainCamera". It will use this camera temporarily and return it to its original position at the end of the conversation.



2. If you assign a camera in the scene to Dialogue Manager > Sequencer Camera, it will create a clone of the camera and temporarily deactivate the original. When the conversation is done, it will destroy the clone and reactivate the original.



3. If you assign a prefab, it will instantiate a copy of the camera and temporarily deactivate the current MainCamera. When the conversation is done, it will destroy this instantiated copy and reactivate the MainCamera.
bautistac
Posts: 14
Joined: Tue Jan 06, 2015 5:31 pm

Camera Doesn't Return After Sequence

Post by bautistac »

I have 1 camera in scene tagged as MainCamera and I have a sequence camera prefab. I tried tagging the sequence cam as MainCamera and also untagged and neither work.



My camera is still not reactivating. If I look at my main camera after the cutscene, it is disabled. I have received this error



NullReferenceException: Object reference not set to an instance of an object

PixelCrushers.DialogueSystem.Sequencer.TakeCameraControl ()



When I don't set a sequence camera on the dialogue manager, the camera will return at "required Camera(original)@{{end}}" , but when the rest of the conversation finishes, the camera detaches from the player and orients itself away from it.
bautistac
Posts: 14
Joined: Tue Jan 06, 2015 5:31 pm

Camera Doesn't Return After Sequence

Post by bautistac »

I think I figured it out. The conversation wasn't set for my player to be the actor so I was still able to move around during the cutscene. I guess the original position is stored relative to cam angle position so it didn't translate back to the same spot.



Is there a way to have the camera slowly move to its angle, rather than popping into it? I would also like to restore player control during a conversation. Is there anyway I can turn off the "Set Enabled on Dialogue Event" for an actor via conversation node? If not, I can just split my conversation up and not include my player as an actor when I need to have controls. My conversations are all one-sided narrator messages so it seems to be okay if I don't have my player as an actor.
User avatar
Tony Li
Posts: 20864
Joined: Thu Jul 18, 2013 1:27 pm

Camera Doesn't Return After Sequence

Post by Tony Li »

(I'm replacing my previous reply here since you resolved the issue.)



To smoothly move the camera, use the syntax: Camera(angle, subject, duration) where:



angle: the camera angle to use

subject: the target for the camera angle

duration: the amount of time to smoothly move from the camera's current position to the desired position



For example, to do a smooth closeup on the speaker over 2 seconds, use:

Camera(Closeup, speaker, 2)

If you want to restore player control of the camera at some point in a conversation, use this Sequence:

SendMessage(ReleaseCameraControl,,Dialogue Manager);

SetEnabled(component, true, subject)

For the SendMessage() command, note the double commas. This means the second parameter is empty, and the third parameter is "Dialogue Manager".



For the SetEnabled() command, specify the name of the player camera control component in place of "component", and specify the camera GameObject name in place of "subject". You can use multiple SetEnabled() commands if you need to enable more components.
bautistac
Posts: 14
Joined: Tue Jan 06, 2015 5:31 pm

Camera Doesn't Return After Sequence

Post by bautistac »

Thank for the offer, Tony, but I think I have it figured out now. Sorry for the simple questions, too.



I have my camera transitioning nicely over time now. I left the sequence camera empty on the Dialogue Manager and disabled the camera controls during cutscene. That seems to have been the issue with it leaving my player after the conversation.
User avatar
Tony Li
Posts: 20864
Joined: Thu Jul 18, 2013 1:27 pm

Camera Doesn't Return After Sequence

Post by Tony Li »

Okay, glad everything's working. I seem to be doing a wonderful job of timing my replies and edits completely wrong today. :-)
bautistac
Posts: 14
Joined: Tue Jan 06, 2015 5:31 pm

Camera Doesn't Return After Sequence

Post by bautistac »

I added the sequence for ReleaseCameraControl. For some reason, it is returning to the angle and subject that I set 2 nodes prior to this sequence.



Here's what I have in my conversation:



Node1: Camera(Wide, Target, 4);

Node2: required Camera(original,,1)@{{end}}

Node3: SendMessage(ReleaseCameraControl,,Dialogue Manager); SetEnabled(MyMouseLook, true, PlayerCamera);SetEnabled(MyMouseLook, true, Player);SetEnabled(FPSWalker, true, Player);



My camera returns in node 2. Then, in node 3 it jumps back to what was set in node 1. My controls come back but the camera is so far off from the player that it becomes unplayable.
User avatar
Tony Li
Posts: 20864
Joined: Thu Jul 18, 2013 1:27 pm

Camera Doesn't Return After Sequence

Post by Tony Li »

Try putting Camera(original) at the very beginning of Node 3's sequence. I had made the assumption earlier that a gameplay script was controlling the camera position every frame. It looks like you're perhaps instead making the camera a child of the player so it follows relative to the player's transform.
bautistac
Posts: 14
Joined: Tue Jan 06, 2015 5:31 pm

Camera Doesn't Return After Sequence

Post by bautistac »

I put Camera(original) where you suggested and it seems to be working now.



Thanks for the help!
Post Reply