are there any errors in my script for move player ?

my script for move:

using UnityEngine;

public class PlayerMouvement : MonoBehaviour
{
public float MoveSpeed;

public Rigidbody2D rb;
private Vector3 velocity = Vector3.zero;

void Update()
{
float horizontalMovement = Input.GetAxis(“Horizontal”) * moveSpeed * Time.deltaTime;

MovePlayer(horizontalMouvement)
}

void MovePlayer(float _horizentalMouvement)
{
Vector3 targetVelocity = new Vector2 (_horizentalMouvement, rb.velocity.y);
rb.velocity = Vector3.SmoothDamp(rb.velocity, targetVelocity, ref velocity,05f)
}
}

Pls help me

and i am in Visual Studio Code

Instead of spamming, could format your code and edit your post to contain a proper question.

4 Likes

how ?

using UnityEngine;

public class PlayerMouvement : MonoBehaviour
{
public float MoveSpeed;

public Rigidbody2D rb;
private Vector3 velocity = Vector3.zero;

void Update() 
{
float horizontalMovement = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime;

MovePlayer(horizontalMouvement)
}

void MovePlayer(float _horizentalMouvement)
{
Vector3 targetVelocity = new Vector2 (_horizentalMouvement, rb.velocity.y);
rb.velocity = Vector3.SmoothDamp(rb.velocity, targetVelocity, ref velocity,05f)
}
}

Step 1: Read the very first post in this forum: Using Code Tags Properly.
Step 2: Post your question observing Step 1
Step 3: Everyone loves you
Step 4: You receive no response
Step 5: You realize that you still did not post a question.
Step 6: Enlightment ensues
???
Step 8: Everyone profits

what ?

So

  1. Use [code ] not [icode ]. The formatting is better and you get line numbers.
  2. Don’t just say “script errors”. Copy and paste the actual errors. The errors have a lot of information that will allow use to go straight to the problem.
  3. Begging (“pls help me”) only makes us annoyed
  4. You’re missing several semicolons, which is probably your problem.
  5. Don’t let the fact that I gave you #4 make you think it’s okay to ignore 1-3 in future posts

are there any errors in my script ?

 using UnityEngine;

public class PlayerMouvement : MonoBehaviour
{
    public float MoveSpeed;

    public Rigidbody2D rb;
    private Vector3 velocity = Vector3.zero;
   
    void Update()
    {
        float  horizontalMovement = Input.GetAxis("Horizontal") * moveSpeed  * Time.deltaTime;

        MovePlayer(horizontalMouvement)
      }

    void MovePlayer(float _horizentalMouvement)
    {
        Vector3 targetVelocity = new Vector2 (_horizentalMouvement, rb.velocity.y);
        rb.velocity = Vector3.SmoothDamp(rb.velocity, targetVelocity, ref velocity,05f)
    }
}


Source: Console Window - Unity - Manual

My error Assets\script\PlayerMouvement.cs(20,88): error CS1002: ; expected

Seems like a pretty straightforward and helpful error to me - tells you exactly what you need to add and where.

You have a missing semicolon on line 20.

(Quite a drawn-out thread for this to be the issue).

1 Like

new error : Assets\script\PlayerMouvement.cs(14,40): error CS1002: ; expecte

I understood thank you very much

Now your missing a semicolon on line 14 :wink: