Finally bots can die. Player to. And another fixes.
This commit is contained in:
@ -11,7 +11,7 @@ public class Shooting : MonoBehaviour
|
||||
[SerializeField] private GameObject projectilePrefab;
|
||||
|
||||
private float hSliderValue = 0.1f;
|
||||
private float _fireCountdown = 1f;
|
||||
private float _fireCountdown = 0.1f;
|
||||
|
||||
public GameObject gun;
|
||||
private void Update()
|
||||
@ -25,10 +25,24 @@ public class Shooting : MonoBehaviour
|
||||
{
|
||||
_fireCountdown = 0;
|
||||
_fireCountdown += hSliderValue;
|
||||
Shoot();
|
||||
PlayerShoot();
|
||||
}
|
||||
_fireCountdown -= Time.deltaTime;
|
||||
}
|
||||
|
||||
private void PlayerShoot()
|
||||
{
|
||||
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
||||
if (Physics.Raycast(raycast.transform.position,
|
||||
raycast.transform.forward, out var hit,
|
||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||
{
|
||||
if (hit.transform.TryGetComponent<NPC>(out var target))
|
||||
{
|
||||
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Shoot()
|
||||
{
|
||||
@ -36,7 +50,7 @@ public class Shooting : MonoBehaviour
|
||||
raycast.transform.forward, out var hit,
|
||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||
{
|
||||
if (hit.transform.TryGetComponent<NPC>(out var target))
|
||||
if (hit.transform.TryGetComponent<ICharacter>(out var target))
|
||||
{
|
||||
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
||||
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
||||
|
Reference in New Issue
Block a user