Created
May 6, 2020 07:52
-
-
Save SenpaiRar/d40a8504650f4873e85bb8b17ac2a98d 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; | |
public class Pea :Bullet | |
{ | |
public int DamageValue; | |
public float Speed; | |
public float TimeToDestroy; | |
float timer; | |
private void Start(){ | |
StartCoroutine(Lifespan()); | |
} | |
private void FixedUpdate() | |
{ | |
transform.Translate(Vector3.forward*Speed*Time.deltaTime, Space.Self); | |
} | |
void OnTriggerEnter(Collider Col){ | |
if(Col.tag == "Enemy" || Col.tag=="Enemy_Bullet"){ | |
Entity x = Col.gameObject.GetComponent<Entity>(); | |
x.TakeDamage(DamageValue); | |
Destroy(gameObject); | |
} | |
Debug.Log("Encounted Collision"); | |
} | |
public override int GetDamage() | |
{ | |
return (DamageValue); | |
} | |
IEnumerator Lifespan(){ | |
yield return new WaitForSecondsRealtime(10.0f); | |
Destroy(gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment