-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathHitImpact.cs
More file actions
96 lines (75 loc) · 1.65 KB
/
HitImpact.cs
File metadata and controls
96 lines (75 loc) · 1.65 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HitImpact : MonoBehaviour {
[Header("True = Impact | False = Hit")]
public bool TypeImpact = false;
public bool Active = false;
public GameObject ImpactEffect;
TrailRenderer trail;
FightModule holder;
[HideInInspector] public float HeavyForce;
[HideInInspector] public float LightForce;
// Use this for initialization
void Start () {
Initialization();
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(TypeImpact)
{
HitImpact other_hit = other.gameObject.GetComponent<HitImpact>();
if(other_hit != null)
{
if(other_hit.Active)
{
Impacted(other.transform.position, other_hit.HeavyForce);
}
}
}
}
void Impacted(Vector3 pos, float force)
{
Debug.Log(force);
GameObject p = Instantiate(ImpactEffect, pos, ImpactEffect.transform.rotation) as GameObject;
holder.Impacted(force);
}
public void ParticleImpact()
{
Impacted(transform.position, 150);
}
public void Switch(bool state)
{
Active = state;
if(Active)
{
trail.enabled = true;
}
else
{
trail.enabled = false;
}
}
void SetTrail()
{
trail = GetComponent<TrailRenderer>();
if(trail)
{
trail.enabled =false;
}
}
void Initialization()
{
SetTrail();
holder = transform.root.gameObject.GetComponent<FightModule>();
}
public void SetForces(float light, float heavy)
{
LightForce = light;
HeavyForce = heavy;
Debug.Log(HeavyForce);
}
}