start work on implementing gameplay

This commit is contained in:
Sylvia 2026-06-25 15:15:16 -07:00
parent 94f5a5e209
commit 274af1e5a1
42 changed files with 3054 additions and 371 deletions

View file

@ -0,0 +1,31 @@
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);
}
}
}