i am new to unity and i am trying to make a script with c# to move forward but an error keeps coming up

the error says vector3.forward can not be assigned to (it is read only)
this is my script

using UnityEngine;
using System.Collections;

public class basicmove : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
	transform.Translate (Vector3.forward = Input.GetAxis ("Vertical") * Time.deltaTime);
}

}

I’m guessing:

transform.Translate (Vector3.forward = Input.GetAxis ("Vertical") * Time.deltaTime);

is meant to be:

transform.Translate (Vector3.forward * Input.GetAxis ("Vertical") * Time.deltaTime);

or, possibly:

transform.Translate (transform.forward * Input.GetAxis ("Vertical") * Time.deltaTime);

Hello @wstuy1 ,
This is the possible solution:

using UnityEngine; 
using System.Collections;

public class basicmove : MonoBehaviour 
{
    public float MoveSpeed = 10;

    // Use this for initialization
    void Start () 
    {
     
    }
     
    // Update is called once per frame
    void Update () 
   {
     float MoveForward = Input.GetAxis("Vertical")  * MoveSpeed * Time.deltaTime;
     transform.Translate(Vector3.forward * MoveForward);
   }
}

You should not assign any value to Vector3.forward which is the cause for the error you getting. @tanoshimi is also correct.

Do accept the Answer and ThumbsUp if its Helpful :slight_smile: