Last active
November 5, 2019 12:59
-
-
Save Plnda/e5b8c43a98e8c010844a3774ed10e371 to your computer and use it in GitHub Desktop.
This file contains 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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
[RequireComponent(typeof(Weapon))] | |
public class Controller : MonoBehaviour | |
{ | |
// Start is called before the first frame update | |
Weapon weapon; | |
void Start() | |
{ | |
weapon = this.GetComponent<Weapon>(); | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
} | |
void OnTriggerEnter(Collider other) | |
{ | |
var zombieController = other.gameObject.GetComponent<ZombieController>(); | |
if(zombieController != null) | |
{ | |
zombieController.TakeDamage(weapon.dmg); | |
} | |
} | |
} | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Weapon : MonoBehaviour | |
{ | |
public float dmg = 10.0f; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment