-
Notifications
You must be signed in to change notification settings - Fork 520
Open
Description
using UnityEngine.SceneManagement;
// This script was modified by the Unity Script Modification Tool
using UnityEngine;
public class PlayerController : MonoBehaviour
{
public float speed = 5f;
void Update()
{
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector2 movement = new Vector2(moveHorizontal, moveVertical);
transform.Translate(movement * speed * Time.deltaTime);
}
}
void OnCollisionEnter2D (Collision2D collision)
{
if (collision.gameObject.CompareTag ("Obstacle"))
{
Time.timeScale = 0f;
StartCoroutine (RestartGameAfterDelay ());
}
}
IEnumerator RestartGameAfterDelay ()
{
yield return new WaitForSecondsRealtime (2f);
Time.timeScale = 1f;
SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
}
Metadata
Metadata
Assignees
Labels
No labels