random stuff i forgot to commit
This commit is contained in:
parent
274af1e5a1
commit
b0625ae834
59 changed files with 7806 additions and 664 deletions
32
Assets/Scripts/Projectiles/Projectile.cs
Normal file
32
Assets/Scripts/Projectiles/Projectile.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class Projectile : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
public int damage;
|
||||
public float speed;
|
||||
public float lifetime;
|
||||
public Vector2 direction;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Destroy(gameObject, lifetime);
|
||||
direction = transform.right;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = direction * speed;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (!other.CompareTag(tag) && other.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
isEntity.TakeDamage(damage);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Projectiles/Projectile.cs.meta
Normal file
2
Assets/Scripts/Projectiles/Projectile.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6cb8b1c6e38733b8a846a00e4b0ad87b
|
||||
Loading…
Add table
Add a link
Reference in a new issue