Home > Back-end >  How do I get this information from another script?
How do I get this information from another script?

Time:08-09

How can I create a if statement in my rigTransform script that does this?: (if the PickupAndDrop script pickup void weapon1Layer.enabled = false)

//this script is called RigTransform:
{
    PickupAndDrop GET;
    public RigTransform rigTransform;
    // Start is called before the first frame update
    void Start()
    {
        rigTransform.enabled = false;
    }

    // Update is called once per frame
    void Update()
    {
       if(GET.PickUp().weapon1Layer.enabled = false)
        { 

        }
        
    }
}

//this script is called PickupAndDrop:

public void PickUp()
    {
        weapon1Layer.enabled = false;
        weapon1Layer.weight = 1f;
        currentWeapon = wp;
        currentWeapon.transform.position = equipPosition.position;
        currentWeapon.transform.parent = equipPosition;
        currentWeapon.transform.localEulerAngles = new Vector3(0f, 180f, 0);
        currentWeapon.GetComponent<Rigidbody>().isKinematic = true;
    }

CodePudding user response:

Change the RigTransform script so that it reads:

    // Update is called once per frame
    void Update()
    {
       if(!GET.weapon1Layer.enabled)
        { 

        }
        
    }

you should also make the PickupAndDrop GET variable public, so you can set the reference yourself or program some sort of Function that does it programmatically.

  • Related