snozbot / fungus

An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
MIT License
1.6k stars 291 forks source link

Change Camera Z without modifying code #931

Open burningthumb opened 3 years ago

burningthumb commented 3 years ago

Currently the CameraManager has this hardcoded:


        [Tooltip("Set the camera z coordinate to a fixed value every frame.")]
        [SerializeField] protected bool setCameraZ = true;

        [Tooltip("Fixed Z coordinate of main camera.")]
        [SerializeField] protected float cameraZ = -10f;

It seems to mean that if I don't want the Camera locked to Z = -10 I need to modify the code.

It should be that there is a way to change both the bool and the float without the need to modify the code. Perhaps from a flowchart?

Arylos07 commented 3 years ago

Anyone is free to join in on this.

Variables in Fungus are set to protected so they can't be accessed by external classes. This is usually to protect specific variables while also cutting down on programming clutter. You could make a child of the CameraManager that will have access to those values and you can modify them from there.

If you're trying to get a reference to the variable from another script, this won't be possible. The best way to do this will be to change the variable from protected to public or write a function in CameraManager that adjusts the variable that is public.

CG-Tespy commented 3 years ago

I was working on a solution to this, and then saw that the CameraManager didn't do any of the aforementioned position-fixing. I made my branch off the latest commit in develop, too. Am I missing something, or...?