Answer the question
In order to leave comments, you need to log in
Error: Does the non-static field, method, or property 'GameObject.transform' require an object reference?
How to solve this problem?
the code:
void FixedUpdate()
{
if (UnityEngine.Input.GetKey(KeyCode.W))
{
GameObject.transform.position = new Vector2(GameObject.transform.position.x,
y: GameObject.transform.position.y + 1.79f);
}
if (UnityEngine.Input.GetKey(KeyCode.S))
{
GameObject.transform.position = new Vector2(GameObject.transform.position.x,
y:GameObject.transform.position.y - 1.79f);
}
if (UnityEngine.Input.GetKey(KeyCode.A))
{
GameObject.transform.position = new Vector2(x:GameObject.transform.position.x + 1.79f,
GameObject.transform.position.y);
}
if (UnityEngine.Input.GetKey(KeyCode.D))
{
GameObject.transform.position = new Vector2(x:GameObject.transform.position.x - 1.79f,
GameObject.transform.position.y + 1.79f);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question