This error just keeps coming up error CS0019: Operator `+' cannot be applied to operands of type `UnityEngine.Vector3' and `float'

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

public class Move : MonoBehaviour {

public float speed;

// Use this for initialization
void Start () {
	
}

// Update is called once per frame
void Update () {

    MoveCube();

}

void MoveCube()
{
    if (Input.GetKeyDown(KeyCode.RightArrow))
    {
        transform.Translate(Vector3.right + speed + Time.deltaTime);
    }

    if (Input.GetKeyDown(KeyCode.LeftArrow))
    {
        transform.Translate(Vector3.left + speed + Time.deltaTime);
    }

    if (Input.GetKeyDown(KeyCode.UpArrow))
    {
        transform.Translate(Vector3.up + speed + Time.deltaTime);
    }

    if (Input.GetKeyDown(KeyCode.DownArrow))
    {
        transform.Translate(Vector3.down + speed + Time.deltaTime);
    }
}

}

Hey! I think your error is that you can’t add things to vector 3s, only other vector 3s, but if you want it to go at the speed you set and by Time.deltaTime, you need to multiply it on, which gives the same effect.

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

public class CheckColor : MonoBehaviour
{

    public float speed;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        MoveCube();
    }
    void MoveCube()
    {
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            transform.Translate(Vector3.right * speed * Time.deltaTime);
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            transform.Translate(Vector3.left * speed * Time.deltaTime);
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            transform.Translate(Vector3.up * speed * Time.deltaTime);
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            transform.Translate(Vector3.down * speed * Time.deltaTime);
        }
    }
}

Hope this helps you :slight_smile: