private void Flip() { rb.velocity = new Vector2(0, 0); Vector3 dir = surr.DirectionToNearestObject(); if (dir.x > -1 && dir.x < 1) { if (dir.x < 0) { dir = new Vector3(-1f * 3, dir.y, dir.z); } if (dir.x >= 0) { dir = new Vector3(1f * 3, dir.y, dir.z); } } rb.AddForce(-dir.normalized * -jumpStrength); rb.angularVelocity = new Vector3(Random.Range(30, maxAngularVelocity.x), rb.angularVelocity.y, Random.Range(30, maxAngularVelocity.z)); //Jump spin }