回答編集履歴
2
eeee
answer
CHANGED
@@ -11,9 +11,12 @@
|
|
11
11
|
//対象のオブジェクト
|
12
12
|
public GameObject desObj;
|
13
13
|
private bool isRespon = false;
|
14
|
+
private Vector3 initPos;
|
14
15
|
|
15
16
|
// Use this for initialization
|
16
|
-
void Start () {
|
17
|
+
void Start () {
|
18
|
+
//初期値設定
|
19
|
+
this.initPos = Vector3.zero;
|
17
20
|
}
|
18
21
|
// Update is called once per frame
|
19
22
|
void Update () {
|
@@ -23,6 +26,7 @@
|
|
23
26
|
time=0.0f;
|
24
27
|
isRespon = false;
|
25
28
|
this.desObj.SetActive(true);
|
29
|
+
this.desObj.transform.positon=firstPos;
|
26
30
|
}
|
27
31
|
}
|
28
32
|
}
|
1
kousinn
answer
CHANGED
@@ -10,20 +10,26 @@
|
|
10
10
|
|
11
11
|
//対象のオブジェクト
|
12
12
|
public GameObject desObj;
|
13
|
+
private bool isRespon = false;
|
13
14
|
|
14
15
|
// Use this for initialization
|
15
16
|
void Start () {
|
16
17
|
}
|
17
18
|
// Update is called once per frame
|
18
19
|
void Update () {
|
20
|
+
if(isRespon){
|
19
21
|
time += Time.deltaTime;
|
20
22
|
if(time >= 3.0f){
|
23
|
+
time=0.0f;
|
24
|
+
isRespon = false;
|
21
25
|
this.desObj.SetActive(true);
|
22
26
|
}
|
27
|
+
}
|
23
28
|
}
|
24
29
|
void OnCollisionEnter2D(Collision2D coll){
|
25
30
|
if(coll.gameObject.tag == "Player"){
|
26
31
|
this.desObj.SetActive(false);
|
32
|
+
isRespon = true;
|
27
33
|
//または
|
28
34
|
//coll.gameObject.SetActive(false);
|
29
35
|
}
|