Exemple #1
0
    private void OnTriggerEnter(Collider other)
    {
        GameObject       otherGameObject  = other.gameObject;
        GravityShiftable gravityShiftable = otherGameObject.GetComponent <GravityShiftable>();
        Rigidbody        rigidbody        = otherGameObject.GetComponent <Rigidbody>();

        if (gravityShiftable != null && rigidbody != null)
        {
            if (rigidbody.useGravity)
            {
                rigidbody.useGravity = false;
                gravityShiftable.gravityDirection = Vector3.up;
                if (overrideMagnitude)
                {
                    gravityShiftable.magnitude = magnitude;
                }
                else
                {
                    gravityShiftable.magnitude = Physics.gravity.magnitude;
                }
            }
            else
            {
                rigidbody.useGravity = true;
            }
        }
    }
 // Use this for initialization
 void Start()
 {
     gravityShiftable = GetComponent <GravityShiftable> ();
     rb = GetComponent <Rigidbody> ();
 }