stopping the game and show an animation to user for the points
Hello, I need and example similar to the Roll-a-ball tutorial (https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial) on your website but when the player hits the balls, the game stops and as feedback an animation will be shown for instance points go up (shown to player). Then the player continue the game. I was wondering if you guys can help me with this?
Thank you
Answer by AtticRoomBoy · Sep 25, 2015 at 12:58 PM
Here is a rough script that slows down time when the player hits an object and then calls a coroutine that plays an animation for 1 second and then reverts time back to normal.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SlowTimeScript : MonoBehaviour {
public GameObject animationImage;
void OnTriggerEnter(Collider coll)
{
if (coll.tag == "Player")
{
Time.timeScale = 0.2f;
StartCoroutine(WaitForAnimation());
}
}
IEnumerator WaitForAnimation()
{
animationImage.GetComponent<Animator>().SetBool("Animate", true);
yield return new WaitForSeconds(1f);
animationImage.GetComponent<Animator>().SetBool("Animate", false);
Time.timeScale = 1f;
}
}
Your answer
Follow this Question
Related Questions
need an example: stop the game while playing an animation to players 0 Answers
Cannot apply indexing with [] to an expression of type 'Animator' 1 Answer
There is no lighting and animation in game preview 0 Answers
Play an animation only when a scene is loaded for the first time? 0 Answers
Enemy Animation Play 0 Answers