http://answers.unity3d.com/questions/1187219/slow-motion-effect-on-trigger.html
Which moderator published this??
Slow Motion PowerUp
I am trying to make a slow motion powerup using Time.timeScale, but I am running into several issues. I have watched many tutorials and searched unityanswers for a solution, but almost all the answers discuss initializing the effect on mouseclick down.
Issues:
When the player collides with the powerup the game goes into slowmotion, but the powerup is not destroyed, the sound never plays, and I want to figure out how to keep the player's Time.timeScale at 1 (or normal speed) while slow motion is in effect.
Here is my code:
using UnityEngine;
using System.Collections;
using UnityEngine .Audio ;
using UnityEngine .SceneManagement ;
public class Player : MonoBehaviour {
public float speed;
public AudioClip slowDown;
void Awake ()
{
}
void Start(){
}
void Update()
{
}
public void OnTriggerEnter2D(Collider2D other){
if (other.tag == "Slow Down Clock") {
GameObject sound = new GameObject();
sound.transform.position = transform.position;
AudioSource audioSource = sound.AddComponent<AudioSource>();
audioSource.clip = slowDown ;
audioSource.Play();
Time.timeScale = 0.5f;
Destroy (sound, slowDown.length);
Destroy (other.gameObject);
}
}
}
Your help is appreciated!
Follow this Question
Related Questions
Timer onTriggerEnter doesn't launch 0 Answers
Slow Motion Effect on Trigger 0 Answers
Powerup Timer Help 0 Answers
PowerUp Tutorials 1 Answer