Jump to content

Does anyone know how to fix these issues

Jamchuck

I wrote this code and imported it to unity

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

public class movement : MonoBehaviour
{
    public float _speed = 5f;
    private void Start()
    {

    }
    private void Update()
    {
        var movement; - Input.GetAxis("Horizontal");
        var _move = Input.GetAxis("Horizontal");
        transform.position = transform.position + new Vector3(_move * _speed * Time.deltaTime, 0, 0);
        Console.WriteLine(movement);
        
    }
};

and got these errors

Assets\movement.cs(15,23): error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

Assets\movement.cs(15,13): error CS0818: Implicitly-typed variables must be initialized

does anybody know how to fix it

Link to comment
Share on other sites

Link to post
Share on other sites

17 minutes ago, Sauron said:

...can you spot the syntax error?

Thanks for pointing that out

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now