Camera not repositioning correctly

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
protemus
Posts: 3
Joined: Wed Jan 04, 2017 1:45 am

Camera not repositioning correctly

Post by protemus »

I have been playing around with sequences and have run into an issue with the Camera Angles. In the "Cam Angles" tab, I set my angle correctly for a close up shot of my character's head. But when the LUA sequence fires off in the game, the camera is set to a different position. The camera is placed in some scaled or offset position from where I set it up. I actually managed to see my character in the repositioned camera (just by moving the reference object and hitting play over an over and just happened to hit a position where my character is visible), but now, when my character moves and I kick off the sequence again, the camera goes back to the exact same world position instead of being offset along with my character and being relative to my character.

I really need some help here, at this point the cutscene sequences are unusable.

The setup is really basic and there isn't much going on in my game yet. Just an active camera and a secondary camera I use for the sequences.

Any idea why running this LUA in a sequence: Camera(CharCloseup,Character1); would not be positioning the camera relative to the Character1 Gameobject and instead would be positioned using world coordinates? The view when I look in the "Cam Angles" tab is correct but it doesn't seem to translate properly in game.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Camera not repositioning correctly

Post by Tony Li »

Hi,

If CharCloseup is a loose GameObject in your scene, the Camera() sequencer command will move the camera to its exact world position.

If CharCloseup is a child GameObject underneath the GameObject or prefab that you've assigned to the Dialogue Manager's Display Settings > Camera Settings > Camera Angles field, it will determine CharCloseup's offset from its parent. Then it will position the camera at this offset from the subject (e.g., Character1). You can see an example picture here:
Image
This assumes you've assigned to the Dialogue Manager's Camera Angles field a GameObject structure something like this:
  • Camera Angles [parent object]
    • Closeup - local position: (0,2,1)
If the camera is moving to CharCloseup's world position, make sure CharCloseup's parent is assigned to the Dialogue Manager's Camera Angles field.

If that doesn't help, please let me know. If you can post a screenshot that would help. Or also feel free to send an example to tony (at) pixelcrushers.com. I'll be happy to take a look.
protemus
Posts: 3
Joined: Wed Jan 04, 2017 1:45 am

Re: Camera not repositioning correctly

Post by protemus »

Ok,

But that means then that common camera angles for characters of the same height need to be uniquely named and then duplicated under each character you use in your cutscenes... that seems strange but I guess necessary.

I did what you said and parented the angles to the characters and it seems to work... (so long as the Camera Angles parent object is at 0,0,0 offset from the character)

One other question:

In the demo the camera animates to the camera angle. In my project, the camera flips immediately to the new angle. Are there examples of Lua code that will make the camera fly to each new location over time?

Also, My main camera is a static angle and sometimes I would like to start the camera animation by matching the position of the other camera in my scene. Is it possible to match one camera to another in Lua code?

Thanks for all your help so far! great response time!
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Camera not repositioning correctly

Post by Tony Li »

protemus wrote:But that means then that common camera angles for characters of the same height need to be uniquely named and then duplicated under each character you use in your cutscenes... that seems strange but I guess necessary.
If you set up your common camera angles as children of your camera angles prefab/GameObject, you can re-use them for all characters of the same height. They don't need to be unique. The Feature Demo scene is an example. Since the Dialogue Manager's Camera Settings > Camera Angles field is unassigned, it uses the default camera angles prefab located in Assets > Dialogue System > Prefabs > Camera Angles > Resources. Private Hart's conversation uses angles such as "Closeup" and "Medium Right", which are children of this prefab.

If you were to add another NPC somewhere else in the scene, you could use those same camera angles. Since they're children of the camera angles prefab, the offsets will apply relative to whichever NPC they're focusing on.

If a character has a different height, such as a child or a small critter, you'll want to define a new camera angle. The video tutorial has an example starting at 02:52.
protemus wrote:In the demo the camera animates to the camera angle. In my project, the camera flips immediately to the new angle. Are there examples of Lua code that will make the camera fly to each new location over time?
As the third parameter, provide the duration over which you'd like it to fly. For example:

Code: Select all

Camera(CharCloseup, Character1, 2.5)
This will cause the camera to move from its current position to the CharCloseup position over 2.5 seconds.

Another thing to note: If your sequence has multiple sequencer commands, each one will try to run immediately unless you've specified a time to start using the "@" format. For example:

Code: Select all

Camera(CharCloseup, speaker, 2.5);
Camera(Wide, speaker, 0.5)@3.5;
AnimatorPlay(Explode)@5.0
This will move the camera to the CharCloseup angle on the current speaker over 2.5 seconds. It will stay there for 1.0 seconds. At the 3.5-second mark, it will move to a Wide angle on the speaker over 0.5 seconds. At the 5.0-second mark, the speaker will play its Explode animator state.

(BTW, these are sequencer commands, not Lua code. Think of sequencer commands as things that typically change visible stuff, whereas Lua code changes data such as internal dialogue database variables and quest states.)
protemus wrote:Also, My main camera is a static angle and sometimes I would like to start the camera animation by matching the position of the other camera in my scene. Is it possible to match one camera to another in Lua code?
If your moving camera is assigned to the Dialogue Manager's Camera Settings > Sequencer Camera, it should automatically start at your main camera's position when the conversation/sequence starts. If it doesn't, check that your main camera is actually tagged MainCamera. To move the sequencer camera back to the original position, use the 'original' keyword:

Code: Select all

Camera(original)
This again assumes that your main camera is tagged MainCamera. Otherwise the Dialogue System won't know which camera is actually your main camera.
protemus
Posts: 3
Joined: Wed Jan 04, 2017 1:45 am

Re: Camera not repositioning correctly

Post by protemus »

Wow thanks! That got me where I want to be.

Is there a list of sequencer commands or the ability to add more via C# script?
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: Camera not repositioning correctly

Post by Tony Li »

protemus wrote:Is there a list of sequencer commands or the ability to add more via C# script?
Yes to both! :-)
Third party support packages also have their own sequencer commands. For example, the Cinema Director Support package adds a command to kick off a Cinema Director cutscene, the NJG MiniMap Support package adds commands to show items on the minimap, etc.
Post Reply