finally get pathfinding done?

This commit is contained in:
reisenlol 2026-01-10 02:37:44 -08:00
parent 7b151c1a53
commit 7bd61df481
No known key found for this signature in database
23 changed files with 1408 additions and 785 deletions

View file

@ -0,0 +1,53 @@
using System;
using UnityEngine;
public class RangedWeapon : Weapon
{
private Camera cam;
private Vector3 mousePos;
public bool fired;
public bool isAiming;
[SerializeField] private Projectile projectile;
private void Start()
{
cam = Camera.main;
}
public override void TryAttack()
{
if (!fired)
{
fired = true;
AttackEffects();
}
}
public void Reload()
{
fired = false;
}
protected override void AttackEffects()
{
isAiming = true;
}
private void Update()
{
if (isAiming)
{
mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
if (Input.GetMouseButtonDown(0))
{
CreateProjectile(mousePos);
isAiming = false;
}
}
}
private void CreateProjectile(Vector3 target)
{
Projectile newProjectile = Instantiate(projectile, transform.position, Quaternion.identity);
newProjectile.RotateToTarget(target);
newProjectile.tag = tag;
}
}