PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, June 25, 2022

[FIXED] Why am I getting a CS1001 error in my code?

 June 25, 2022     c#, compiler-errors, identifier, unity3d     No comments   

Issue

I am a complete novice at C# coding so this might be a dumb question, but I can't figure out why I keep getting this error from my Unity script. It says "identifier expected," but as far as I know I already have an identifier?

{

    public float moveSpeed = 5f;

    public Rigidbody2D rb;

    public string animator;
    public string movement;

    Vector2 (movement);
    
    // Update is called once per frame
    void Update()
    {
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        animator.SetFloat("Horizontal", movement.x);
        animator.SetFloat("vertical", movemnet.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);
    }

    void FixedUpdate()
    {
        rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
    }

}

Solution

Why are there parenthesis around movement in Vector2 (movement);

Also this variable needs to be initialized with a value.

Try Vector2 movement = new Vector2(0,0);

Also a spelling error here animator.SetFloat("vertical", *movemnet*.y);



Answered By - Eric Breyer
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing