-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGravity.cs
50 lines (35 loc) · 1000 Bytes
/
Gravity.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
using UnityEngine;
using System.Collections;
//script used to see if we want to enable gravity on progectiles
//this is used so bullets dont droop when fired but also dont float randomly away when they collide with other objects
public class Gravity : MonoBehaviour {
//nullreference happens but does not change gameplay
public Rigidbody RB;
public AudioVolume audioVolume;
// Use this for initialization
void Start ()
{
audioVolume = GetComponent<AudioVolume>();
}
// Update is called once per frame
void Update ()
{
}
void OnCollisionEnter(Collision coll)
{
//if enemies hit self or other enemies ignore for gravity
if (coll.gameObject.tag == "Enemy")
{
}
else if (coll.gameObject.tag == "Claw")
{
Destroy(this);
}
else
{
//turn gravity sound on
RB.useGravity = true;
audioVolume.PlayMusic();
}
}
}