Exemple #1
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag != "Player" && other.gameObject.tag != "RopeSegment")
     {
         Rigidbody2D otherBody = other.transform.GetComponent <Rigidbody2D>();
         if (otherBody != null)
         {
             float angleAmount = AngleDir(other.transform.position, centerPiece.position);
             otherBody.AddForce(Vector2.up * bounceForce * (gameCon.PlayerDistance() - gameCon.minPlayerDistance));
             otherBody.AddForce(Vector2.right * angleForce * (gameCon.PlayerDistance() - gameCon.minPlayerDistance) * angleAmount * -1);
             if (!bounceSource.isPlaying)
             {
                 bounceSource.Play();
             }
         }
     }
 }
 // Update is called once per frame
 void Update()
 {
     playerDistance = gameCon.PlayerDistance();
     InputContoller();
 }