using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Player : MonoBehaviour
{
[SerializeField] KeyCode keyOne;
[SerializeField] KeyCode keyTwo;
[SerializeField] KeyCode keyFree;
[SerializeField] KeyCode keyFour;
[SerializeField] Vector3 moveDirection;
private void FixedUpdate()
{
if (Input.GetKey(keyOne))
{
GetComponent<Rigidbody>().velocity += moveDirection;
}
if (Input.GetKey(keyTwo))
{
GetComponent<Rigidbody>().velocity -= moveDirection;
}
if(Input.GetKey(KeyFree))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
if(Input.GetKey(KeyFour))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
private void OnTrigger(Collider other)
{
if(this.CompareTag("Player" && other.CompareTag("Finish")
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Player : MonoBehaviour
{
[SerializeField] KeyCode keyOne;
[SerializeField] KeyCode keyTwo;
[SerializeField] KeyCode keyFree;
[SerializeField] KeyCode keyFour;
[SerializeField] Vector3 moveDirection;
private void FixedUpdate()
{
if (Input.GetKey(keyOne))
{
GetComponent<Rigidbody>().velocity += moveDirection;
}
if (Input.GetKey(keyTwo))
{
GetComponent<Rigidbody>().velocity -= moveDirection;
}
if(Input.GetKey(KeyFree))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
if(Input.GetKey(KeyFour))
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
private void OnTrigger(Collider other)
{
if(this.CompareTag("Player" && other.CompareTag("Finish")
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
}
}