Example #1
0
    private void Start()
    {
        mom = transform.parent.GetComponent <THController>();

        canTurnLeft  = true;
        canTurnRight = true;
    }
Example #2
0
 private void OnCollisionExit2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("Player"))
     {
         thc = collision.gameObject.GetComponent <THController>();
         thc.isBeingPushed = false;
     }
 }
Example #3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            thc = collision.gameObject.GetComponent <THController>();

            if (inMotion)
            {
                Vector2 dir = (Vector2)collision.gameObject.transform.position - collision.contacts[0].point;
                collision.gameObject.GetComponent <Rigidbody2D>().AddForce(dir * pushSpeed);
                thc.stunTime      = 3;
                thc.isHit         = true;
                thc.isBeingPushed = false;

                mom.source.PlayOneShot(mom.hit);
            }
            if (!inMotion)
            {
                thc.isBeingPushed = true;
            }
        }
    }