So I have to create a mini game where the camera has to move with the arrow keys.
I have seen this post : Moving Camera with WASD - Questions & Answers - Unity Discussions
But the problem is I want the WASD keys for moving my player and the camera has to move independently so the examples presented there are not working for me.
If for example I use the code presented there :
void Update () {
inputX = Input.GetAxis ("Horizontal");
inputZ = Input.GetAxis ("Vertical");
if (inputX != 0)
{
rotate ();
}
if (inputZ != 0)
{
move ();
}
}
void rotate()
{
transform.Rotate (new Vector3 (0f, inputX * Time.deltaTime, 0f));
}
void move()
{
transform.position += transform.forward * inputZ * Time.deltaTime;
}
Then the camera moves fine with the arrow keys but also moves when using WASD.
Since I’m very new to Unity and C# any help will be much appreciated.