help scripting error ( error CS1525: Unexpected symbol `anim')

dunno what wrong with this code can someone please help me asap much appreciated and here’s the code

using UnityEngine;
using System.Collections;

public class PlayerMovement : MonoBehaviour {
    Transform mainCamera;
    private Animator anim;
    private float vertical;
    private float horizontal;

    void Start () {
        anim = GetComponent <Animator>();
    }

    void Update ()
    {
        float xVelocity = Input.GetAxis("Horizontal") * moveSpeed;
        float zVelocity = Input.GetAxis("Vertical") * movespeed;
        transform.position += new Vector3(xVelocity, 0f, zVelocity) * Time.deltaTime
           
        anim.SetFloat("xVelocity", xVelocity);
        anim.SetFloat("zVelocity", zVelocity);
    }
}

i’m trying to get my character to move like this is there a way in using a 2d blend tree to achieve this type of movement

video

*note that around 12 seconds to 19 is the type of movement I wan’t to achieve and also from 1:44 to 1:49 is how I wan’t to get my character to move here’s one more example to show what I’m trying to achieve

*note 2:24-2:27 is how I wan’t my character to move so how would I get my character to move like that with my script also I need the error fixed so I can continue

semicolon on line 18

1 Like

i think you didnt set anim correctly as currently anim will be null.
add gameobjec.getcomponent().

ok now it says move speed does not exist?

says move speed does not exist now

says move speed does not exist

because you did not define movespeed*
look at line 16 and 17

so would I put GetAxis = movespeed(“Vertical”); ?

Beginner tutorials