I am new to coding and c#, but I have been trying to make my player without gravity affecting it. But my player keeps moving up and doing nothing else. I have started by trying to make it move to the left and right. I am not sure where I went wrong or if I should start over as I am not to far in or if I should fix a small mistake.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement1 : MonoBehaviour
{
private float speed;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
Vector2 direction = new Vector2(horizontalInput, verticalInput);
transform.Translate(direction * speed * Time.deltaTime);
}
}