-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer2_atkV1.cs
83 lines (58 loc) · 1.52 KB
/
Player2_atkV1.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player2_atkV1 : MonoBehaviour
{
bool punch_b = false;
bool kick_b = false;
private float atkTimer = 0;
private float atkCd = 0.3f;
public Collider2D player2_triggerV1;
public Animator animator;
void Awake()
{
animator = gameObject.GetComponent<Animator>();
player2_triggerV1.enabled = false;
}
void Update()
{
if (Input.GetKeyDown("i") && !punch_b)
{
punch_b = true;
atkTimer = atkCd;
player2_triggerV1.enabled = true;
}
if (punch_b)
{
if (atkTimer > 0)
{
atkTimer -= Time.deltaTime;
}
else
{
punch_b = false;
player2_triggerV1.enabled = false;
}
}
animator.SetBool("punch_b", punch_b);
if (Input.GetKeyDown("o") && !kick_b)
{
kick_b = true;
atkTimer = atkCd;
player2_triggerV1.enabled = true;
}
if (kick_b)
{
if (atkTimer > 0)
{
atkTimer -= Time.deltaTime;
}
else
{
kick_b = false;
player2_triggerV1.enabled = false;
}
}
animator.SetBool("kick_b", kick_b);
}
}