Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var enemyTarget : GameObject;
- var countDown : int = 0;
- var coolDown : int = 2;
- var playerAttackRange : int = 2;
- var player : GameObject;
- var timeSpeed : int = 1;
- var particle : GameObject;
- function Update() {
- if(countDown > 0) {
- countDown -= 1 * Time.deltaTime;
- }
- if(countDown < 0) {
- countDown = 0;
- }
- if(Input.GetKeyUp(KeyCode.F)) {
- Debug.Log("Attacked");
- Slash();
- //Debug.Log(enemyTarget.GetComponent(BadGuyHealth).currentEnemyHealth);
- }
- }
- function Slash() {
- var hit : RaycastHit;
- var fwd = transform.TransformDirection (Vector3.forward);
- if (Physics.Raycast (transform.position, fwd, hit, playerAttackRange)) {
- if(hit.collider.gameObject.tag == "Enemy") {
- Debug.Log(hit.collider.gameObject.GetComponent(BadGuyHealth).currentEnemyHealth);
- hit.collider.gameObject.GetComponent(BadGuyHealth).currentEnemyHealth -= player.GetComponent(Statistics).Strength;
- Instantiate (particle, transform.position, transform.rotation);
- //Play attack animation.
- //if (hit.collider.gameObject.GetComponent(EnemyHealth).enemyHealth <= 10) {
- // Time.timeScale = timeSpeed;
- //}
- }
- }
- }
Add Comment
Please, Sign In to add comment