Player Facing Property Access in Camera Script

Currently using Unity 2017.3.0f3, and it seems as if the character had a default PlatformerCharacter2D script tied to it. I want to make the private bool m_FacingRight variable public or let my CameraRunner script have access to it, but I’m not sure how to access it from CameraRunner. The public Transform player; variable doesn’t seem to have access to the public method I made to get the value.

How do I access the facing value so that I can adjust the camera position + 6 for facing right and -6 for facing left?

if you want to access it from another script ,it should be a public variable,

for example

//script1

public bool m_FacingRight;

//Script2

public script1 s1;

    void Start(){

    s1=FindObjectOfType< script1> ();//now you can access to script1 with s1

//this code search all objects in the scene and will find the object that has script1 script.
}

public void accessToScriptOne(){

     s1.m_FacingRight=true;

       }

You have to edit the PlatformerCharacter2D script. Either make the variable public from

private bool m_FacingRight;

to

public bool m_FacingRight;

or create a property for it

private bool m_FacingRight;

public bool FacingRight
{
    get { return m_FacingRight; }
}

In order to access the variable, you need a reference to the PlatformerCharacter2D script.

private PlatformerCharacter2D platformChar2D;
platformChar2D = player.GetComponent<PlatformerCharacter2D>()

Now you can access the variable from the script using the two methods posted above. If you change it to a public variable

platformChar2D.m_FacingRight

or use the property method

platformChar2D.FacingRight