Skip to content

Instantly share code, notes, and snippets.

@SenpaiRar
Created May 6, 2020 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SenpaiRar/d40a8504650f4873e85bb8b17ac2a98d to your computer and use it in GitHub Desktop.
Save SenpaiRar/d40a8504650f4873e85bb8b17ac2a98d to your computer and use it in GitHub Desktop.
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