Item.cs
1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Item : MonoBehaviour {
Transform transform;
AudioSource Caudio;
public float rotationSpeed = 30;
// Use this for initialization
private void Awake()
{
Caudio = GetComponent<AudioSource>();
}
void Start () {
transform = GetComponent<Transform>();
}
// Update is called once per frame
void Update () {
transform.Rotate(new Vector3(0, rotationSpeed, 0) * Time.deltaTime);
//회전
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.tag == "Player")
{
Time.timeScale = 0;
collision.gameObject.transform.localScale *= 1.5f;
Debug.Log(collision.gameObject.transform.localScale);
StartCoroutine(ScaleUpSound());
//Time.timeScale = 1;
}
}
IEnumerator ScaleUpSound()
{
Caudio.PlayOneShot(Caudio.clip, 1.0f);
Debug.Log("Caudio Playing");
yield return new WaitWhile(() => Caudio.isPlaying);
Destroy(gameObject);
Time.timeScale = 1;
}
}