I found a few similar asked questions but the solutions for which gave me errors while compiling.
Also, a code I used to move it using the arrow keys made it move just 1 unit per key press, despite it being in the Update() snippet, which just didn’t make sense to me.
The code I used is as follows:-
using UnityEngine;
using System.Collections;
public class Ctrl : MonoBehaviour
{
void Update ()
{
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
Vector3 position = this.transform.position;
position.x--;
this.transform.position = position;
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
Vector3 position = this.transform.position;
position.x++;
this.transform.position = position;
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
Vector3 position = this.transform.position;
position.y++;
this.transform.position = position;
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
Vector3 position = this.transform.position;
position.y--;
this.transform.position = position;
}
}
}
Thanks for being such a wonderful community !