void PlaceTemporaryWall(BouncePoint bp) { Transform wall = wallsPool.GetChild(bouncePoints.Count - 1); wall.gameObject.SetActive(true); wall.position = bp.position.XYZ(wall.position.z); wall.up = bp.direction.XYZ(0); wall.position -= wall.right * (wall.localScale.x + ball.GetComponent <CircleCollider2D>().radius); }
// creates the two points for the wall (and ground) based on the bounce point of index : index // List<Vector2> will always contain 2 points List <Vector2> generateWallPoints(int index) { Vector2 minMaxLength = new Vector3(1, 5); List <Vector2> pts = new List <Vector2>(); BouncePoint bp = bouncePoints[index]; float dist = Random.Range(minMaxLength.x, minMaxLength.y); Vector2 pt1 = bp.position + -bp.direction * dist; dist = Random.Range(minMaxLength.x, minMaxLength.y); Vector2 pt2 = bp.position + bp.direction * dist; pts.Add(pt1); pts.Add(pt2); return(pts); }