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!
- This topic has 2 replies, 3 voices, and was last updated 1 year ago by Terence.
-
AuthorPosts
-
October 17, 2023 at 4:02 am #12081::
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); } } }
October 27, 2023 at 4:41 am #12122::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”)
October 29, 2023 at 12:17 pm #12127::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
(); } // 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); } } } -
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: