Making a racing game already got the movement and camera to follow the player im working on a feature where if the player holds down the space key there speeds increase but i keep getting this error.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 5.0f;
public float turnspeed;
public float horizontalInput;
public float forwardInput;
// Update is called once per frame
void Update()
{
horizontalInput = Input.GetAxis("Horizontal");
transform.Rotate(Vector3.up, Time.deltaTime * turnspeed * horizontalInput);
forwardInput = Input.GetAxis("Vertical");
transform.Translate(Vector3.forward * Time.deltaTime * speed * forwardInput);
bool held = Input.GetKey(KeyCode.Space);
if (held)
{
speed * 2.0f;
}
}
}
↧