Skip to content

Instantly share code, notes, and snippets.

@remusjones
Created May 17, 2016 11:44
Show Gist options
  • Select an option

  • Save remusjones/caad04b66ac8f124554774cc210f5964 to your computer and use it in GitHub Desktop.

Select an option

Save remusjones/caad04b66ac8f124554774cc210f5964 to your computer and use it in GitHub Desktop.
// 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);
}
}
// 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