Forum rules - please read before posting.

Modyfiyng basicCamera focal distance (target)

Hey,
What I would need is like what GameCamera has - but for basicCamera. Setting up focal distance as target object, and kind of have no idea how to aproach this?

Thanks for any tips

Comments

  • It can be done with a separate script, attached to the same object.

    Paste this into a script named SetFocalDistance.cs, attach to the Basic Camera, and fill in its Inspector:

    using UnityEngine;
    using AC;
    
    public class SetFocalDistance : MonoBehaviour
    {
    
        public _Camera acCamera;
        public Transform target;
    
        protected void Update ()
        {
            if (target)
            {
                float focalDistance = Vector3.Dot (Transform.forward, target.position - Transform.position);
                if (focalDistance < 0f)
                {
                    focalDistance = 0f;
                }
                acCamera.focalDistance = focalDistance;
            }
        }
    
    }
    
  • Thanks Chris,
    getting some errors on the script ( An object reference is required for the non-static field, method, or property)

    will try to look into it afternoon

  • changed Transform.forward/Transform.position to acCamera.transform.forward/acCamera.transform.position and it seems to work as intended,

    Thanks again Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.