Page 1 of 1
Set camera to follow head
Posted: Sun Aug 25, 2019 11:18 am
by fanaei
Hi Tony,
Using different camera angles for sitting positions or positions with different heights is a bit annoying. I wanted to know if there's a way to set a child of Speaker For example the head of main object as the subject for Dialogue camera to follow?
I used this code:
Code: Select all
DialogueManager.StartConversation (ConversationName, Player.transform, NpcObject.transform.Find ("Body"));
It works for Camera but as the Animator component is on the Parent Object, it can't run sequencer commands like this:
AnimatorPlay(angry,,0.3,);
Re: Set camera to follow head
Posted: Sun Aug 25, 2019 11:47 am
by Tony Li
Hi,
Here are two ideas:
1. Use a
Default Camera Angle component. If you know the character will be seated, you can define a lower camera angle in your camera angles prefab such as "Closeup Seated", and set the character's Default Camera Angle to "Closeup Seated". Then use the keyword "default" with the Camera() command:
2. Or give the character's head a unique GameObject name such as "Adam Head". Then you can use commands such as:
or
(The LiveCamera() command will follow Adam Head over 3 seconds even if Adam Head is moving.)
Or you create an empty GameObject that's a child of Adam's head, such as "Adam Camera Angle", and tell the camera to move to that position:
You can combine this with the Default Camera Angle component if you prefer. In that case, you'd set the Default Camera Angle to "Adam Camera Angle" and use the sequencer command Camera(default).
Re: Set camera to follow head
Posted: Sun Aug 25, 2019 12:05 pm
by fanaei
I think your solutions don't work.
Because not all the NPC characters are seated, so I can't use default camera angle for all NPCs.
Also there are lots of NPCs, so I can't use a unique object name for default camera.
Re: Set camera to follow head
Posted: Sun Aug 25, 2019 12:35 pm
by Tony Li
Add the Default Camera Angle component to each character.
For example, let's say:
- Adam is seated. You want to use the camera angle "Closeup Seated", which is like "Closeup" but lower.
- Bob is a big guy. You need to use the camera angle "Wide" to fit him in the view.
- Carl has an empty GameObject named "Carl Head". You want the camera to move to the position of Carl Head.
Add a Default Camera Angle to each character.
- On Adam's Default Camera Angle component, set the angle to "Closeup Seated".
- On Bob's Default Camera Angle, set the angle to "Wide".
- On Carl's Default Camera Angle, set the angle to "Carl Head".
Now whenever you use this command: Camera(default, speaker)
it will move the camera to these locations:
- Speaker is Adam: A Closeup Seated angle on Adam.
- Speaker is Bob: A Wide angle on Bob.
- Speaker is Carl: Camera will move to Carl Head.
Re: Set camera to follow head
Posted: Thu Aug 29, 2019 9:55 am
by fanaei
Thank you Tony. It sounds a good solution. I should try it.
Re: Set camera to follow head
Posted: Mon Sep 09, 2019 10:05 am
by fanaei
I tried your solution and it works. thanks
and a small another question:
How can I change the sequence command from the code?
Because I don't wanna use default sequence for some objects and prefer to set it via code.
Re: Set camera to follow head
Posted: Mon Sep 09, 2019 11:08 am
by Tony Li
Hi,
To set a dialogue entry's Sequence at runtime, add a script with an OnConversationLine method to the Dialogue Manager or one of the primary participants. Example:
Code: Select all
void OnConversationLine(Subtitle subtitle)
{
subtitle.sequence = "Delay(5)";
}
Note that you can also use variables in your sequences. So you could set a dialogue entry's Sequence to this in the Dialogue Editor:
- Sequence: LookAt([var=Target])
and in your C# code (or anywhere you can use Lua):
Code: Select all
DialogueLua.SetVariable("Target", someGameObject.name)