-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_chap7.cs
More file actions
39 lines (29 loc) · 975 Bytes
/
Test_chap7.cs
File metadata and controls
39 lines (29 loc) · 975 Bytes
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
private Light theLight;
private float targetIntensity;
private float currentIntensity;
void Start(){
theLight = GetComponent<Light>();
currentIntensity=theLight.intensity;
targetIntensity=Random.Range(0.4f,1f);
}
void Update(){
if(Mathf.Abs(targetIntensity-currentIntensity)>=0.01){
//목표강도와 현재 강도를 맞추기 (최종 모습: 전구 꺼질랑 말랑 하는듯 깜박거림)
if(targetIntensity-currentIntensity>=0)
currentIntensity+=Time.deltaTime*3f;
else{
currentIntensity-=Time.deltaTime*3f;
}
theLight.intensity=currentIntensity;
theLight.range=currentIntensity+10;
}
else{
targetIntensity=Random.Range(0.4f,1f);
}
}
}