Page 1 of 1

Control Camera Sequence Path

Posted: Sat Jun 04, 2016 7:35 am
by field2012
Hi there again,

I am trying to use camerangles to show the location of interest.
The camera angle seems to work well if object is located near. However, I am having trouble to move camera to a place of interest around 500m away and also behind a mountain. Is there a way to make camera avoid the mountain and also show the object with correct camera angle?.

Cheers

Re: Control Camera Sequence Path

Posted: Sat Jun 04, 2016 8:53 am
by Tony Li
Hi,

The Camera() sequencer command does a linear interpolation from the start point to the end point. This means it will move in a straight line.

Here are two options:

1. Use a cutscene editor like SLATE, Cinema Director, uSequencer, or Animator Timeline Editor to define a more complex path around the mountain. You can mix and match Dialogue System sequencer commands and edited cutscenes, only using edited cutscenes where they make life easier for you.

2. Or create empty GameObjects to act as waypoints around the mountain, and string Camera() commands together to follow the waypoints. For example, say you've defined these waypoints at the corners of the mountain: Southwest, Northwest, and Northeast. You want the camera to move from south of the mountain to its northeast corner without going straight through it. You could use this sequence:

Code: Select all

Camera(Southwest,,1);
Camera(Northwest,,1)@1;
Camera(Northeast,,1)@2
Or, if you want to avoid doing the math, you can use ->Message and @Message syntax:

Code: Select all

Camera(Southwest,,1)->Message(AtSouthwest);
Camera(Northwest,,1)@Message(AtSouthwest)->Message(AtNortheast);
Camera(Northeast,,1)@Message(AtNortheast)

Re: Control Camera Sequence Path

Posted: Sat Jun 04, 2016 9:48 am
by field2012
Thanks Tony.

Tried the following option, seems to be working, but as camera moves towards the object, it flips and changes to Down. In a close distance it works fine, but the longer the distance, it flips in negative direction.

Camera(Southwest,,1);
Camera(Northwest,,1)@1;
Camera(Northeast,,1)@2

Re: Control Camera Sequence Path

Posted: Sat Jun 04, 2016 10:24 am
by Tony Li
Are those empty GameObjects oriented correctly? If Northwest, for example, is positioned correctly but is facing down, then the camera will end up looking down. It could be some of kind floating point accuracy across long distances. Does it help to add more waypoints along the way?

For what it's worth, this is the exact code that it's using to move the camera over time:

Code: Select all

cameraTransform.rotation = Quaternion.Lerp(originalRotation, targetRotation, elapsed);
cameraTransform.position = Vector3.Lerp(originalPosition, targetPosition, elapsed); 
In other words, at every frame it moves the camera somewhere between the original state and the target state based on how long it's been moving.

Please feel free to send an example project or example scene to tony (at) pixelcrushers.com if you want, and let me know what version to Unity to use.

Re: Control Camera Sequence Path

Posted: Sat Jun 04, 2016 9:47 pm
by field2012
Ok its working now after playing around with object positions. They were new object so i though they were oriented correctly, but apparently camera though they were not.

Thanks for your help.

Re: Control Camera Sequence Path

Posted: Sun Jun 05, 2016 12:22 am
by Tony Li
Happy to help!