private void Start() { mom = transform.parent.GetComponent <THController>(); canTurnLeft = true; canTurnRight = true; }
private void OnCollisionExit2D(Collision2D collision) { if (collision.gameObject.CompareTag("Player")) { thc = collision.gameObject.GetComponent <THController>(); thc.isBeingPushed = false; } }
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; } } }