Hello!
I am making this 2D space exploration game, and I want my player to not be stopped the instance the person takes their finger off ‘W’. I would like the object to keep moving at exactly the same speed when the person takes their finger off that key.
Would appreciate any help! Thank you!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour {
public float rotationSpeed = 100f;
public float movementSpeed = 1f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.A)) {
transform.Rotate(Vector3.forward * Time.deltaTime * rotationSpeed);
}
else if (Input.GetKey(KeyCode.D)) {
transform.Rotate(Vector3.back * Time.deltaTime * rotationSpeed);
}
if (Input.GetKey(KeyCode.W)) {
transform.position += transform.up * Time.deltaTime * movementSpeed;
movementSpeed += 0.1f;
}
}
}