[CODE] assign focus to target programmatically

Find the official documentation for Cinema Pro Cams here. Updated as new versions are released.

[CODE] assign focus to target programmatically

Postby DanoG » Wed Sep 09, 2015 1:59 pm

We recently had a Cinema Pro Cams user post the following question:

Is there a way to programmatically assign the focus to a target. On my game
I need to change the focus to a different character.

Here is some code to help you take care of this:

Code: Select all
GameObject proCam; // get the reference to the pro cam
GameObject newFocusTarget; // get the reference to the new target
CameraBody cameraBody = proCam.GetComponent<CameraBody>();
 
float distance = Vector3.Distance(proCam.transform.position, newFocusTarget.position);
if(cameraBody.UnitOfMeasure == UnitOfMeasure.Imperial)
{
    distance = ProCamsUtility.Convert(distance, Units.Meter, Units.Foot);
}
cameraBody.FocusDistance = distance;
DanoG
 
Posts: 236
Joined: Thu Sep 05, 2013 4:36 pm
Location: Burlington, Ontario

Return to Documentation

Who is online

Users browsing this forum: No registered users and 1 guest