I made a simple movement scrip, but if i press any button it just move one, but i need to move until i release the key, can anyone help please ?
Here is the code :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMove : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown("w"))
{
transform.Translate(0, 0, 2);
}
if (Input.GetKeyDown("s"))
{
transform.Translate(0, 0, -2);
}
if (Input.GetKeyDown("d"))
{
transform.Rotate(0.0f, 5.0f, 0.0f, Space.Self);
}
if (Input.GetKeyDown("a"))
{
transform.Rotate(0.0f, -5.0f, 0.0f, Space.Self);
}
if (Input.GetKeyDown("space"))
{
transform.Translate(0, 5, 0);
}
}
}