finally get pathfinding done?
This commit is contained in:
parent
7b151c1a53
commit
7bd61df481
23 changed files with 1408 additions and 785 deletions
35
Assets/Scripts/Projectile.cs
Normal file
35
Assets/Scripts/Projectile.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class Projectile : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Rigidbody2D rb;
|
||||
[Header("Stats")]
|
||||
public float damage;
|
||||
public float speed;
|
||||
public int pierceAmount;
|
||||
private int currentPierce;
|
||||
private void FixedUpdate()
|
||||
{
|
||||
rb.linearVelocity = transform.right * speed;
|
||||
}
|
||||
|
||||
public void RotateToTarget(Vector3 target)
|
||||
{
|
||||
transform.Lookat2D(target);
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (!collision.CompareTag(tag) && collision.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
isEntity.TakeDamage(damage);
|
||||
currentPierce++;
|
||||
if (currentPierce > pierceAmount)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue