I got this this error: "Assets\Movement.cs(18,71): error CS1002: ; expected"

Here’s my code:

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

public class Movement : MonoBehaviour
{

 float speed;


 private void Start()
 {
    Speed = 5;
 }
    // Update is called once per frame
    void Update()
    {
       trasform.translate(("Horizontal") * Time.deltaTime * Speed,0,0)
    }
}

EDIT: I have solved all compiler errors in Unity now. Thanks for all the help!

Please use code tags: Using code tags properly

Not all error messages are necessarily easily understood and straightforward, but this one is: You need a semicolon at the end of the line.

You’ll have more errors after fixing that semicolon error too. Just writing ("Horizontal") in the middle of an if statement is a bit like when Michael Scott declared bankruptcy. On its own it’s meaningless and out of place. I’m assuming you meant to type something like Input.GetAxis("Horizontal") there.

3 Likes

I didn’t look past the semicolon, but yeah good point, there’s a bunch of other things. Also “trasform”->“transform”, and “translate”->“Translate”. You also use inconsistent capitalization for speed/Speed; it can be either, but it has to match.

2 Likes

I haven’t tested, but this might work:

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

public class Movement : MonoBehaviour
{
     float speed;

     private void Start()
     {
          speed = 5f;
     }
    // Update is called once per frame
     void Update()
     {
          transform.Translate(Time.deltaTime * speed,0,0);
     }
}

I actually didn’t notice that, probably because I don’t even know C# and have to google everything, so thanks anyways.

i need some help with this am getting error

Hello

What error? What Code?

Christoph

Please don’t necro post to other peoples ancient threads. It’s against forum rules.

If you’re just making typing mistakes, you can fix those yourself. Here’s how:

Remember: NOBODY here memorizes error codes. That’s not a thing. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The complete error message contains everything you need to know to fix the error yourself.

The important parts of the error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)
  • also possibly useful is the stack trace (all the lines of text in the lower console window)

Always start with the FIRST error in the console window, as sometimes that error causes or compounds some or all of the subsequent errors. Often the error will be immediately prior to the indicated line, so make sure to check there as well.

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.