can you help me with this problem
I have this code to make the player move put it doesn’t work the player didn’t move
public class movement : MonoBehaviour {
private Rigidbody2D reg;
public float speed = 10f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
reg = GetComponent<Rigidbody2D>();
var newx = 0f;
var newy = 0f;
if (Input.GetKey("right")){
newx = speed;
}else if (Input.GetKey("lift"))
{
newx = -speed;
} else if (Input.GetKey("up"))
{
newy = speed;
}
reg.AddForce(new Vector2(newx, newy));
}
}
I hope i can find the solution for this problem ,hello…