// Update is called once per frame void Update() { GravitySource source = gravityObject.GetGravitySource(); Vector3 target = source != null ? new Vector3(source.transform.position.x, source.transform.position.y, transform.position.z) : new Vector3(player.transform.position.x, player.transform.position.y, transform.position.z); transform.position = Vector3.Lerp(transform.position, target, 0.3f); }
private void OnTriggerExit2D(Collider2D collision) { if (collision.tag.Equals("Player")) { GravityObject go = collision.gameObject.GetComponent <GravityObject>(); if (go.GetGravitySource().Equals(this)) { go.ResetGravity(); } } }
private void OnTriggerExit2D(Collider2D collision) { GravityObject go = collision.gameObject.GetComponent <GravityObject>(); if (go != null && go.isActiveAndEnabled) { if (this.Equals(go.GetGravitySource())) { go.ResetGravity(); } } }
private void OnTriggerStay2D(Collider2D collision) { //if (collision.tag.Equals("Player")) { //GravityObject go = collision.gameObject.GetComponent<GravityObject>(); GravityObject go = collision.gameObject.GetComponent <GravityObject>(); if (go != null) { if (go.GetGravitySource() == null) { go.UseGravity(this); } } }