blob: d4839bf9ed9ae0ee6f543c10c01509c577a517ee (
plain)
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
|
using UnityEngine;
//Player PlayerKnockback ¶¯×÷-»÷ÍË
public class PlayerKnockback : MonoBehaviour
{
private RigidbodyHolder allRigs;//14
private StandingDataHandler standing;
private WeaponHandler weapons;
private void Start()
{
allRigs = GetComponent<RigidbodyHolder>();
standing = GetComponent<StandingDataHandler>();
weapons = GetComponent<WeaponHandler>();
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.K)) //kill
{
AddSeriousKnockback();
}
}
public void AddForce(Vector3 force, Rigidbody rig)
{
if (force.magnitude > 200f)
{
AddSeriousKnockback();
force *= 0.1f;
}
for (int i = 0; i < allRigs.GetAllRigs().Length; i++)
{
float num = 1f;
if (rig == allRigs.GetAllRigs()[i])
{
num *= 1f;
}
allRigs.GetAllRigs()[i].AddForce(force * num * 20f, ForceMode.Acceleration);
}
}
private void AddSeriousKnockback()
{
GetComponent<PlayerDeath>().Kill();
}
private void AddNormalKnockback()
{
}
}
|