-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathitem.cs
108 lines (88 loc) · 2.92 KB
/
item.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class item : MonoBehaviour
{
Transform breadEquipPoint; //개미다리
Rigidbody rb;
bool isParent;
//public bool isParent;
int i = -1;
void Awake()
{
rb = gameObject.GetComponent<Rigidbody>(); //빵의 리지드바디 가져오기
}
// Start is called before the first frame update
void Start()
{
if (Input.GetKeyDown(KeyCode.A))
{
breadEquipPoint = GameObject.FindGameObjectWithTag("EquipPoint_A").GetComponent<Transform>();
i = 0;
}
else if (Input.GetKeyDown(KeyCode.S))
{
breadEquipPoint = GameObject.FindGameObjectWithTag("EquipPoint_S").GetComponent<Transform>();
i = 1;
}
else if (Input.GetKeyDown(KeyCode.K))
{
breadEquipPoint = GameObject.FindGameObjectWithTag("EquipPoint_K").GetComponent<Transform>();
i = 2;
}
else if (Input.GetKeyDown(KeyCode.L))
{
breadEquipPoint = GameObject.FindGameObjectWithTag("EquipPoint_L").GetComponent<Transform>();
i = 3;
}
transform.eulerAngles = new Vector3(0.0f, 90.0f, 270.0f); //회전각도
transform.parent = breadEquipPoint;
}
// Update is called once per frame
void Update()
{
decideParent();
}
void decideParent()
{
if (Player.start)
{
if ((i == 0) && !(Player.isParent_A))
{
Debug.Log("A키 떨어짐");
this.transform.parent = null; //상속해제
this.rb.useGravity = true; //빵에 중력설정해서 바닥으로 떨구기
this.rb.mass = 100; //빵의 질량 100으로 설정
}
else if ((i == 1) && !(Player.isParent_S))
{
Debug.Log("S키 떨어짐");
this.transform.parent = null;
this.rb.useGravity = true;
this.rb.mass = 100;
}
else if ((i == 2) && !(Player.isParent_K))
{
Debug.Log("K키 떨어짐");
this.transform.parent = null;
this.rb.useGravity = true;
this.rb.mass = 100;
}
else if ((i == 3) && !(Player.isParent_L))
{
Debug.Log("L키 떨어짐");
this.transform.parent = null;
this.rb.useGravity = true;
this.rb.mass = 100;
}
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Ground")
{
Debug.Log("충돌");
Destroy(this.gameObject);
}
}
}