Created
May 17, 2016 11:44
-
-
Save remusjones/caad04b66ac8f124554774cc210f5964 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Call on collision enter | |
| void OnCollisionEnter(Collision a_col) | |
| { | |
| // Check if it has already collided | |
| if (HasLandedOnGround) | |
| return; | |
| // Check if the collision is with ground | |
| // child the object at that point | |
| // destroy rigidbody and collider | |
| if (a_col.gameObject.tag == "Ground") | |
| { | |
| HasLandedOnGround = true; | |
| transform.parent = a_col.transform; | |
| transform.localPosition = a_col.transform.InverseTransformPoint(a_col.contacts[0].point); | |
| Destroy(rb); | |
| Destroy(bc); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Check if player is dead | |
| if (m_health <= 0) | |
| { | |
| // Create a new vector3 and store the position | |
| Vector3 newPos = transform.position; | |
| // Loop through and instantiate blood at a random rotation x amount of times | |
| for (int i = 0; i < m_bloodAmount; i++) | |
| { | |
| randomRotation = Quaternion.Euler(Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f), Random.Range(0.0f, 360.0f)); | |
| GameObject obj = Instantiate(m_bloodSplatter, newPos, randomRotation) as GameObject; | |
| } | |
| Destroy(gameObject); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment