I’m learning c# scripting and the book i’m following has the same code but it’s not running for some reason…so please help me where i’m doing wrong …
Here is the code :-
using UnityEngine;
using System.Collections;
public class Input : MonoBehaviour {
public Vector3 pos;
// Use this for initialization
void Start ()
{
pos = transform.position;
}
// Update is called once per frame
void Update ()
{
bool aKey = Input.GetKey (KeyCode.A);
bool dKey = Input.GetKey (KeyCode.D);
bool wKey = Input.GetKey (KeyCode.W);
bool sKey = Input.GetKey (KeyCode.S);
if (aKey)
{
pos.x = pos.x - 0.1f;
}
if (dKey)
{
pos.x = pos.x + 0.1f;
}
if (wKey)
{
pos.z = pos.z + 0.1f;
}
if (wKey)
{
pos.z = pos.z - 0.1f;
}
transform.position = pos;
}
}
and this is the error :-
Input.cs(20,35): error CS0117: Input' does not contain a definition for
GetKey’
Thanks