using UnityEngine;
using UnityEngine.SceneManagement;
public class Player : MonoBehaviour
{
[SerializeField] KeyCode keyOne;
[SerializeField] KeyCode keyTwo;
[SerializeField] Vector3 moveDirection;
private void FixedUpdate()
{
if (Input.GetKey(keyOne))
{
GetComponent<Rigidbody>().linearVelocity += moveDirection;
}
if (Input.GetKey(keyTwo))
{
GetComponent<Rigidbody>().linearVelocity -= moveDirection;
}
}
}
private void OnTriggerEnter(Collider other)
{
if(this.CompageTag("Player") && other.CompageTag("Finish"))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
вот код
using UnityEngine; using UnityEngine.SceneManagement; public class Player : MonoBehaviour { [SerializeField] KeyCode keyOne; [SerializeField] KeyCode keyTwo; [SerializeField] Vector3 moveDirection; private void FixedUpdate() { if (Input.GetKey(keyOne)) { GetComponent<Rigidbody>().linearVelocity += moveDirection; } if (Input.GetKey(keyTwo)) { GetComponent<Rigidbody>().linearVelocity -= moveDirection; } } } private void OnTriggerEnter(Collider other) { if(this.CompageTag("Player") && other.CompageTag("Finish")) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } }
и ошибки
Assets\Player.cs(23,1): error CS0106: The modifier 'private' is not valid for this item
Assets\Player.cs(23,1): error CS8803: Top-level statements must precede namespace and type declarations.