Skip to content

Instantly share code, notes, and snippets.

@IRobS
Last active August 27, 2019 14:23
Show Gist options
  • Save IRobS/7a62ea5c4f6219e7a66547983ffeec50 to your computer and use it in GitHub Desktop.
Save IRobS/7a62ea5c4f6219e7a66547983ffeec50 to your computer and use it in GitHub Desktop.
Damage Player - this requires that the player has a PlayerLife script with the ability to "takeDamage"
/**
* Damage Player - this requires that the player has a PlayerLife script with the ability to "takeDamage"
*/
background: #d67;
min-height: 100%;
<pre>
<code>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DamagePlayer : MonoBehaviour
{
void OnCollisionEnter(Collision collision)
{
PlayerLife thePlayer = collision.collider.GetComponent&ltPlayerLife&gt();
if (thePlayer != null)
{
thePlayer.takeDamage();
}
}
}
</code>
</pre>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment