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);
}
}
CodePudding user response:
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);