When a character collides with an object in my game, there is a slow motion effect. That's coool, but how would I zoom into a sprite when it collides with another object?
Here is my code currently...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
public float slowness = 2f;
public int index;
private AudioSource hitSource;
public Vector3[] Target;
public Camera Cam;
public float Speed = 0.012f;
public void Start()
{
Cam = Camera.main;
}
public void EndGame()
{
Application.targetFrameRate = 300;
StartCoroutine(RestartLevel());
hitSource = GetComponent<AudioSource>();
}
IEnumerator RestartLevel()
{
Cam.orthographicSize = Mathf.Lerp(Cam.orthographicSize, 3, Speed);
Cam.transform.position = Vector3.Lerp(Cam.transform.position, Target[1], Speed);
Time.timeScale = 1f / slowness;
Time.fixedDeltaTime = Time.fixedDeltaTime / slowness;
yield return new WaitForSeconds(1.5f/slowness);
Time.timeScale = 1f;
Time.fixedDeltaTime = Time.fixedDeltaTime * slowness;
SceneManager.LoadScene(2);
}
private void OnCollisionEnter(Collision collision)
{
}
}