init
This commit is contained in:
commit
bd5b1556ff
269 changed files with 6249829 additions and 0 deletions
22
Assets/Scripts/Bullet.cs
Normal file
22
Assets/Scripts/Bullet.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Bullet : MonoBehaviour{
|
||||
|
||||
public float speed;
|
||||
|
||||
Rigidbody2D rb2d;
|
||||
|
||||
void Start(){
|
||||
rb2d = GetComponent<Rigidbody2D>();
|
||||
rb2d.AddRelativeForce(Vector2.right * speed, ForceMode2D.Impulse);
|
||||
}
|
||||
|
||||
void OnCollisionEnter2D(Collision2D col){
|
||||
if(col.gameObject.tag == "Dragon"){
|
||||
FindObjectOfType<Dragon>().TakeDamage(5);
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue