Assets\Scripts\Level.cs(60,25): error CS1729: 'Level.Pipe' does not contain a constructor that takes 2 arguments. I got this error and I don't know the solutuon. please guide me. Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Level : MonoBehaviour { private const float CAMERA_ORTHO_SIZE = 50f; private const float PIPE_WIDTH = 13.4f; private const float PIPE_HEAD_HEIGHT = 7.2f; private const float PIPE_MOVE_SPEED = 3f; private List<Pipe> pipeList; private void Awake () { pipeList = new List<Pipe> (); } private void Start () { //CreatePipe(50f, 20f, true); //CreatePipe(50f, 20f, false); CreateGapPipes (50f, 20f, 20f); } private void Update () { HandlePipeMovement (); } private void HandlePipeMovement () { foreach (Pipe pipe in pipeList) { pipe.Move (); } } private void CreateGapPipes (float gapY, float gapSize, float xPosition) { CreatePipe (gapY - gapSize * 0.5f, xPosition, true); CreatePipe (CAMERA_ORTHO_SIZE * 2f - gapY - gapSize * 0.5f, xPosition, false); } private void CreatePipe (float height, float xPosition, bool createBottom) { Transform pipeHead = Instantiate (GameAssets.GetInstance ().pfPipeHead); float pipeHeadYPosition; if (createBottom) { pipeHeadYPosition = -CAMERA_ORTHO_SIZE + height - PIPE_HEAD_HEIGHT * .5f; } else { pipeHeadYPosition = +CAMERA_ORTHO_SIZE - height + PIPE_HEAD_HEIGHT * .5f; } pipeHead.position = new Vector3 (xPosition, pipeHeadYPosition); Transform pipeBody = Instantiate (GameAssets.GetInstance ().pfPipeBody); float pipeBodyYPositon; if (createBottom) { pipeBodyYPositon = -CAMERA_ORTHO_SIZE; } else { pipeBodyYPositon = +CAMERA_ORTHO_SIZE; pipeBody.localScale = new Vector3 (1, -1, 1); } pipeBody.position = new Vector3 (xPosition, pipeBodyYPositon); SpriteRenderer pipeBodySpriteRenderer = pipeBody.GetComponent<SpriteRenderer> ();; pipeBodySpriteRenderer.size = new Vector2 (PIPE_WIDTH, height); BoxCollider2D pipeBodyBoxCollider = pipeBody.GetComponent<BoxCollider2D> (); pipeBodyBoxCollider.size = new Vector2 (PIPE_WIDTH, height); pipeBodyBoxCollider.offset = new Vector2 (0f, height * 0.5f); Pipe pipe = new Pipe (pipeHead, pipeBody); pipeList.Add (pipe); } private class Pipe { private Transform pipeHeadTransform; private Transform pipeBodyTransform; public void pipe (Transform pipeHeadTransform, Transform pipeBodyTransform) { this.pipeHeadTransform = pipeHeadTransform; this.pipeBodyTransform = pipeBodyTransform; } public void Move () { pipeHeadTransform.position += new Vector3 (-1, 0, 0) * PIPE_MOVE_SPEED * Time.deltaTime; pipeBodyTransform.position += new Vector3 (-1, 0, 0) * PIPE_MOVE_SPEED * Time.deltaTime; } } }
remove 'void' in the constructor Code (CSharp): public void pipe (Transform pipeHeadTransform, Transform pipeBodyTransform)
After removing void it is showing now this Assets\Scripts\Level.cs(66,16): error CS1520: Method must have a return type Code (csharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class Level : MonoBehaviour { private const float CAMERA_ORTHO_SIZE = 50f; private const float PIPE_WIDTH = 13.4f; private const float PIPE_HEAD_HEIGHT = 7.2f; private const float PIPE_MOVE_SPEED = 3f; private List<Pipe> pipeList; private void Awake () { pipeList = new List<Pipe> (); } private void Start () { //CreatePipe(50f, 20f, true); //CreatePipe(50f, 20f, false); CreateGapPipes (50f, 20f, 20f); } private void Update () { HandlePipeMovement (); } private void HandlePipeMovement () { foreach (Pipe pipe in pipeList) { pipe.Move (); } } private void CreateGapPipes (float gapY, float gapSize, float xPosition) { CreatePipe (gapY - gapSize * 0.5f, xPosition, true); CreatePipe (CAMERA_ORTHO_SIZE * 2f - gapY - gapSize * 0.5f, xPosition, false); } private void CreatePipe (float height, float xPosition, bool createBottom) { Transform pipeHead = Instantiate (GameAssets.GetInstance ().pfPipeHead); float pipeHeadYPosition; if (createBottom) { pipeHeadYPosition = -CAMERA_ORTHO_SIZE + height - PIPE_HEAD_HEIGHT * .5f; } else { pipeHeadYPosition = +CAMERA_ORTHO_SIZE - height + PIPE_HEAD_HEIGHT * .5f; } pipeHead.position = new Vector3 (xPosition, pipeHeadYPosition); Transform pipeBody = Instantiate (GameAssets.GetInstance ().pfPipeBody); float pipeBodyYPositon; if (createBottom) { pipeBodyYPositon = -CAMERA_ORTHO_SIZE; } else { pipeBodyYPositon = +CAMERA_ORTHO_SIZE; pipeBody.localScale = new Vector3 (1, -1, 1); } pipeBody.position = new Vector3 (xPosition, pipeBodyYPositon); SpriteRenderer pipeBodySpriteRenderer = pipeBody.GetComponent<SpriteRenderer> ();; pipeBodySpriteRenderer.size = new Vector2 (PIPE_WIDTH, height); BoxCollider2D pipeBodyBoxCollider = pipeBody.GetComponent<BoxCollider2D> (); pipeBodyBoxCollider.size = new Vector2 (PIPE_WIDTH, height); pipeBodyBoxCollider.offset = new Vector2 (0f, height * 0.5f); Pipe pipe = new Pipe (pipeHead, pipeBody); pipeList.Add (pipe); } private class Pipe { private Transform pipeHeadTransform; private Transform pipeBodyTransform; public pipe (Transform pipeHeadTransform, Transform pipeBodyTransform) { this.pipeHeadTransform = pipeHeadTransform; this.pipeBodyTransform = pipeBodyTransform; } public void Move () { pipeHeadTransform.position += new Vector3 (-1, 0, 0) * PIPE_MOVE_SPEED * Time.deltaTime; pipeBodyTransform.position += new Vector3 (-1, 0, 0) * PIPE_MOVE_SPEED * Time.deltaTime; } } }