Esempio n. 1
0
    // 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);
    }
Esempio n. 2
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag.Equals("Player"))
     {
         GravityObject go = collision.gameObject.GetComponent <GravityObject>();
         if (go.GetGravitySource().Equals(this))
         {
             go.ResetGravity();
         }
     }
 }
Esempio n. 3
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        GravityObject go = collision.gameObject.GetComponent <GravityObject>();

        if (go != null && go.isActiveAndEnabled)
        {
            if (this.Equals(go.GetGravitySource()))
            {
                go.ResetGravity();
            }
        }
    }
Esempio n. 4
0
    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);
            }
        }
    }