Simple C# Vector2D Moving Question

Hey There! I am having some problems creating a C# script to move my object in a 2D space using Vector2, this is how it looks at the moment, but it gives me a bunch of errors, in line 13. If i change “transform.Translate(Vector2…” to: “Vector2.Up” It works with no errors, but this does not work for me as my object is rotating.

using UnityEngine;
using System.Collections;

public class PControl : MonoBehaviour {

	public float moveSpeed = 10f;

	void Update () {
			transform.Translate(Vector2(0, 1) * moveSpeed * Time.deltaTime);
			Debug.Log ("UP");

Any help is appreciated!

You need the ‘new’ keyword in front of Vector2() in C#. Line 13:

transform.Translate(new Vector2(0, 1) * moveSpeed * Time.deltaTime);

Note that the Vector2 class has a Vector2.up, so you can do:

transform.Translate(Vector2.up * moveSpeed * Time.deltaTime);