Forum begins after the advertisement:


Part 1 – error CS1026 – Great tutorial by the way!

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity Part 1 – error CS1026 – Great tutorial by the way!

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12081
    Felipe Matos
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    I get the following error after following your video. I double checked and I see it is exactly as you typed it. At least 99.9% sure. Can you tell me what’s wrong?

    Assets/Scripts/PlayerController.cs(50,139): error CS1026: ) expected

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class PlayerController : MonoBehaviour
    {
    
        [Header("Horizontal Movement Settings")]
    
        [SerializeField] private float walkSpeed = 1;
    
        [Header("Ground Check Settings")]
        [SerializeField] private float jumpForce = 45;
        [SerializeField] private Transform groundCheckPoint;
        [SerializeField] private float groundCheckY = 0.2f;
        [SerializeField] private float groundCheckX = 0.5f;
        [SerializeField] private LayerMask whatIsGround;
    
        private Rigidbody2D rb;
        private float xAxis;
    
        // Start is called before the first frame update
        void Start()
        {
            rb = GetComponent<Rigidbody2D>();
        }
    
        // Update is called once per frame
        void Update()
        {
            GetInputs();
            Move();
            Jump();
        }
    
        void GetInputs()
        {
            xAxis = Input.GetAxisRaw("Horizontal");
        }
    
        private void Move()
        {
            rb.velocity = new Vector2(walkSpeed * xAxis, rb.velocity.y);
        }
    
        public bool Grounded()
        {
            if (Physics2D.Raycast(groundCheckPoint.position, Vector2.down, groundCheckY, whatIsGround)
                || (Physics2D.Raycast(groundCheckPoint.position + new Vector3(groundCheckX, 0, 0), Vector2.down, groundCheckY, whatIsGround)
                || (Physics2D.Raycast(groundCheckPoint.position + new Vector3(-groundCheckX, 0, 0), Vector2.down, groundCheckY, whatIsGround))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    
        void Jump()
        {
            if (Input.GetButtoneDOwn("Jump") && Grounded())
            {
                rb.velocity = new Vector3(rb.velocity.x, jumpForce);
            }
        }
    }
    #12122
    Aka
    Level 4
    Former Patron
    Helpful?
    Up
    0
    ::

    Assets/Scripts/PlayerController.cs(50,139)

    This mean it’s in the ligne 50

    we don’t know what line 50 is here, but I would say that there is already a problem here : Input.GetButtoneDOwn(“Jump”)

    #12127
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Hi Felipe, sorry I missed your topic. You are missing a few closing brackets in your code on Line 50. I’ve highlighted the parts in the code where the brackets are missing below:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class PlayerController : MonoBehaviour
    {
    
        [Header("Horizontal Movement Settings")]
    
        [SerializeField] private float walkSpeed = 1;
    
        [Header("Ground Check Settings")]
        [SerializeField] private float jumpForce = 45;
        [SerializeField] private Transform groundCheckPoint;
        [SerializeField] private float groundCheckY = 0.2f;
        [SerializeField] private float groundCheckX = 0.5f;
        [SerializeField] private LayerMask whatIsGround;
    
        private Rigidbody2D rb;
        private float xAxis;
    
        // Start is called before the first frame update
        void Start()
        {
            rb = GetComponent<Rigidbody2D>();
        }
    
        // Update is called once per frame
        void Update()
        {
            GetInputs();
            Move();
            Jump();
        }
    
        void GetInputs()
        {
            xAxis = Input.GetAxisRaw("Horizontal");
        }
    
        private void Move()
        {
            rb.velocity = new Vector2(walkSpeed * xAxis, rb.velocity.y);
        }
    
        public bool Grounded()
        {
            if (Physics2D.Raycast(groundCheckPoint.position, Vector2.down, groundCheckY, whatIsGround)
                || (Physics2D.Raycast(groundCheckPoint.position + new Vector3(groundCheckX, 0, 0), Vector2.down, groundCheckY, whatIsGround))
                || (Physics2D.Raycast(groundCheckPoint.position + new Vector3(-groundCheckX, 0, 0), Vector2.down, groundCheckY, whatIsGround)))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    
        void Jump()
        {
            if (Input.GetButtoneDOwn("Jump") && Grounded())
            {
                rb.velocity = new Vector3(rb.velocity.x, jumpForce);
            }
        }
    }
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: