Answer the question
In order to leave comments, you need to log in
Why doesn't Unity recognize KeyCode?
I recently started to try myself in unity and on the first day there was an error..
I have an object like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] KeyCode KeyOne;
[SerializeField] KeyCode KeyTwo;
[SerializeField] Vector3 MoveDirection;
private void FixedUpdate()
{
if(Input.GetKey(KeyOne))
{
GetComponent<RigidBody>().velocity += MoveDirection;
}
if(Input.GetKey(KeyTwo))
{
GetComponent<RigidBody>().velocity -= MoveDirection;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question