简体   繁体   中英

How do I get this information from another script?

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;
    }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM