Guest User

Unity 2D

a guest
Oct 8th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. private void OnCollisionEnter2D(Collision2D collision)
  2.     {
  3.         if (collision.gameObject.tag == "Enemy"  && attackPos.gameObject.activeSelf == true)
  4.         {
  5.             Debug.Log("This will do " + enemy.name);
  6.             //collision.otherCollider(EnemyScript.GetComponent<Rigidbody2D>());
  7.  
  8.             if (facingRight == true)
  9.             {
  10.                 enemy.GetComponent<Rigidbody2D>().AddForce(transform.up * 500 + transform.right * 500);
  11.             }
  12.             else if (facingRight == false)
  13.             {
  14.                 enemy.GetComponent<Rigidbody2D>().AddForce(transform.up * 500 + (transform.right * 500) * -1);
  15.             }
  16.         }
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment