help me fix 3x syntax error ',' expected 2x { expected type or namescape def or end-of-file 2x

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movment : MonoBehaviour
   [SerializeField] Transform playerCamara;
   [SerializeField][Range(0,0f, 0.5f)] float mouseSmoothTime = 0.03f;
   [SerializeField] bool cursorLock = true;
   [SerializeField] float mouseSensitivity = 3.5f;
   [SerializeField] float Speed = 6.0f;
   [SerializeField][Range(0,0f, 0.5f)] float mouseSmoothTime = 0.03f;
   [SerializeField] float gravity = 30f;
   [SerializeField] Transform grouncheck;
   [SerializeField] LayersMask ground;

   public float jumpHeight = 6f;
   float velocityY;
   bool isGrounded;

   float camaraCap;
   Vector2 currentMouseDelta;
   Vector2 currentMouseDeltaVelocity;

   CharacterController controller;
   Vector2 currnetDir;
   Vector2 currentDirVelocity;
   Vector2 velocity;

{
  
    void Start()
    {
        controller = GetComponent<CharacterController>();

        if (cursorLock)
        {
            Curoser.lockState = CursorLockMode.Locked;
            cursorLock.Visable = true;
        }
      
    }

    // Update is called once per frame
    void Update()
    {
      UpdateMouse();
      UpdateMove();
    }
}
    

      void UpdateMouse()
      {
        Vector2 targetMouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));
      
        currentMouseDelta = Vector2.SmoothDamp(currentMouseDelta, targetMouseDelta, ref currentMouseDeltaVelocity, mouseSmoothTime);

        camaraCap = currentMouseDelta.y * mouseSensitivity;

        camaraCap = Mathf.Clamp(camaraCap, -90,0f, 90,0f);

        playerCamara.localEulerAngles = Vector3.right * camaraCap;

        transform.Roatate(Vector3.up * currentMouseDelta.x * mouseSensitivity);

      }

      void UpdateMove()
      {
      
        isGrounded = Physics.CheckSphere(groundCheck.position, 0.2f, ground);

        Vector2 targetDir = new Vector2(Input.GetAxisRaw("Horizantal"), Input.GetAxisRaw("Vertical"));
        targetDir.Dir.Noramlize();

        currnetDir = Vector2.SmoothDamp(currnetDir, targetDir, ref currentDirVelocity, mouseSmoothTime);

        velocityY += gravity * 2f * Time.DeltaTime;

        Vector3 velocity = (transform.forward * currnetDir.y * trasnform.right * currnetDir.x * Speed + Vector3.up * velocityY);

        controller.Move(velocity * Time.DeltaTime);

        if (isGrounded && Input.GetButtonDown("Jump"))
        {
            velocityY = Mathf.Sort(jumpHeight * -2f = gravity);
        }

       

         if (isGrounded! && controller.velocity.y < -1f)
         {
             velocity = -8f;
         }
      }

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movment : MonoBehaviour
[SerializeField] Transform playerCamara;
[SerializeField][Range(0,0f, 0.5f)] float mouseSmoothTime = 0.03f;
[SerializeField] bool cursorLock = true;
[SerializeField] float mouseSensitivity = 3.5f;
[SerializeField] float Speed = 6.0f;
[SerializeField][Range(0,0f, 0.5f)] float mouseSmoothTime = 0.03f;
[SerializeField] float gravity = 30f;
[SerializeField] Transform grouncheck;
[SerializeField] LayersMask ground;

public float jumpHeight = 6f;
float velocityY;
bool isGrounded;

float camaraCap;
Vector2 currentMouseDelta;
Vector2 currentMouseDeltaVelocity;

CharacterController controller;
Vector2 currnetDir;
Vector2 currentDirVelocity;
Vector2 velocity;

{

void Start()
{
controller = GetComponent();

if (cursorLock)
{
Curoser.lockState = CursorLockMode.Locked;
cursorLock.Visable = true;
}

}

// Update is called once per frame
void Update()
{
UpdateMouse();
UpdateMove();
}
}

void UpdateMouse()
{
Vector2 targetMouseDelta = new Vector2(Input.GetAxis(“Mouse X”), Input.GetAxis(“Mouse Y”));

currentMouseDelta = Vector2.SmoothDamp(currentMouseDelta, targetMouseDelta, ref currentMouseDeltaVelocity, mouseSmoothTime);

camaraCap = currentMouseDelta.y * mouseSensitivity;

camaraCap = Mathf.Clamp(camaraCap, -90,0f, 90,0f);

playerCamara.localEulerAngles = Vector3.right * camaraCap;

transform.Roatate(Vector3.up * currentMouseDelta.x * mouseSensitivity);

}

void UpdateMove()
{

isGrounded = Physics.CheckSphere(groundCheck.position, 0.2f, ground);

Vector2 targetDir = new Vector2(Input.GetAxisRaw(“Horizantal”), Input.GetAxisRaw(“Vertical”));
targetDir.Dir.Noramlize();

currnetDir = Vector2.SmoothDamp(currnetDir, targetDir, ref currentDirVelocity, mouseSmoothTime);

velocityY += gravity * 2f * Time.DeltaTime;

Vector3 velocity = (transform.forward * currnetDir.y * trasnform.right * currnetDir.x * Speed + Vector3.up * velocityY);

controller.Move(velocity * Time.DeltaTime);

if (isGrounded && Input.GetButtonDown(“Jump”))
{
velocityY = Mathf.Sort(jumpHeight * -2f = gravity);
}

if (isGrounded! && controller.velocity.y < -1f)
{
velocity = -8f;
}
}[/code]

Looks like you tried to use code tags, but maybe deleted the starting tag.

Luckily, your typo at the top at least is easy to spot.


That bracket is not where it’s suppose to be.

1 Like

where do i put it

Hopefully you’re able to figure out how to get rid of the duplicated text.

But I can already see you have multiple misspellings, and have your brackets in all the wrong places.

You should be able to look at any other script to see where it goes. But, a hint is declaring variables should always be within the { and not before it.

@Brathnann are you able to see this site in dark mode??? please teach me! A white background is like a High-powered LED flashlight in my face, lol

where do i put the bracket

im new to unity so i followed a tutorial so idk how to fix it please help @Brathnann

But yes, the open bracket at 29 needs to be at 6. The close bracket at 49 needs to be at 96. And the misspellings I’ll figure out later, lol

Standard practice of class containment should look like this:

public class MyClass : MonoBehaviour
{
   // variable declarations
   // Start() { }
   // Update() { }
   // functions/methods { }
}

It doesn’t have to be in that particular order, but the first and the end bracket do.

This is C# for beginners. https://learn.microsoft.com/en-us/shows/c-fundamentals-for-absolute-beginners/

it left me with 4 errors ‘RangeAttribute’ dose not contain a constructor that takes 3 arguments x2
the type ‘Movment’ already contains a defition for ‘mouseSmoothTime’
the type or namescape Name LayersMask could not be found

It’s a Firefox plugin called Dark Reader. It might be available on other browsers as well. :slight_smile:

If you are following a tutorial, then you should go back to the tutorial. While there are some bad tutorials, chances are this isn’t one of them and I suggest looking over their script line by line and comparing it to yours. That will be super helpful. To Quote “Everything must be typed exactly right!”.

i did it is if you can help me with fixing the code that would be great cus i reallly want my player to move its very disapoiting when your cide diosent work

That’s because your spelling is horrible… no offense… But everything in code is “exact”, and any misplaced letter or symbol, especially “CAPITAL” versus “lowercase” letters can easily break your code.

So you may be in a hurry, which I admit I do myself, but you really gotta take your time and read and reread and reread again to make sure everything is typed exactly right… Or nothing will work… ever…

Now, I went through and fixed all your spelling errors, but it would just be easier to delete that script and make a new one, with this pasted into it:

public class Movement : MonoBehaviour // was Movment
{
    [SerializeField] Transform playerCamera; // was playerCamara
    [SerializeField][Range(0,0f, 0.5f)] float mouseSmoothTime = 0.03f;
    [SerializeField] bool cursorLock = true;
    [SerializeField] float mouseSensitivity = 3.5f;
    [SerializeField] float Speed = 6.0f;
    [SerializeField][Range(0,0f, 0.5f)] float mouseSmoothTime = 0.03f;
    [SerializeField] float gravity = 30f;
    [SerializeField] Transform groundCheck; // was grouncheck
    [SerializeField] LayersMask ground;

    public float jumpHeight = 6f;
    float velocityY;
    bool isGrounded;

    float cameraCap; // was camaraCap
    Vector2 currentMouseDelta;
    Vector2 currentMouseDeltaVelocity;

    CharacterController controller;
    Vector2 currentDir; // was currnetDir
    Vector2 currentDirVelocity;
    Vector2 velocity;
    void Start()
    {
        controller = GetComponent<CharacterController>();
        if (cursorLock)
        {
            Cursor.lockState = // was Curoser.lockState
                   CursorLockMode.Locked;
            cursorLock.Visable = true;
        }
    }

    void Update()
    {
        UpdateMouse();
        UpdateMove();
    }

    void UpdateMouse()
    {
        Vector2 targetMouseDelta = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

        currentMouseDelta = Vector2.SmoothDamp(currentMouseDelta, targetMouseDelta, ref currentMouseDeltaVelocity, mouseSmoothTime);

        cameraCap = currentMouseDelta.y * mouseSensitivity;

        cameraCap = Mathf.Clamp(cameraCap, -90,0f, 90,0f);

        playerCamera.localEulerAngles = Vector3.right * cameraCap;

        transform.Rotate( // was transform.Roatate
            Vector3.up * currentMouseDelta.x * mouseSensitivity);
    }
    void UpdateMove()
    {
        isGrounded = Physics.CheckSphere(groundCheck.position, 0.2f, ground);

        Vector2 targetDir = new Vector2(
            Input.GetAxisRaw("Horizontal"), // was Horizantal
            Input.GetAxisRaw("Vertical"));
        targetDir.Dir.Normalize(); // was Dir.Noramlize

        currentDir = // was currnetDir
            Vector2.SmoothDamp(currentDir, targetDir, ref currentDirVelocity, mouseSmoothTime);

        velocityY += gravity * 2f * Time.DeltaTime;

        Vector3 velocity = (transform.forward * currentDir.y * transform.right // was trasnform
                     * currentDir.x * Speed + Vector3.up * velocityY);

        controller.Move(velocity * Time.DeltaTime);

        if (isGrounded && Input.GetButtonDown("Jump"))
        {
            velocityY = Mathf.Sort(jumpHeight * -2f = gravity);
        }

        if (isGrounded! && controller.velocity.y < -1f)
        {
            velocity = -8f;
        }
    }
}

Because changing the script name after it’s been made is a nightmare to fix. So much easier to just make a new one. So test out the code I provided and see what fails then. But be sure to give us a proper line(number) error so we can see where the issue is.

Edit: I must have reread this script 10 times, and I’m still finding spelling mistakes… oof… never doing that again, lol

1 Like

Closing this thread because the forum is not here to correct typos or teach the very basics of C#. The forums assume a basic knowledge of the language.

1 Like