ошибки поворота, прицела
This commit is contained in:
1 parent
202a894140
commit
da648df1d9
200 files changed
+31969
-629
No files matched your search
@@ -143,23 +143,43 @@ public class PlayerGun : MonoBehaviour
|
||||
// (ЛКМ в этом случае используется скриптом PlayerAttack для рукопашного удара)
|
||||
if (!isGunEquipped) return;
|
||||
|
||||
// 4. Выстрел (ЛКМ)
|
||||
// 4. Прицеливание (ПКМ) при оружии в руках
|
||||
if (Mouse.current.rightButton.isPressed)
|
||||
{
|
||||
FaceAimTarget(0.15f);
|
||||
}
|
||||
|
||||
// 5. Выстрел (ЛКМ)
|
||||
bool shootInput = isAutomatic
|
||||
? Mouse.current.leftButton.isPressed
|
||||
: Mouse.current.leftButton.wasPressedThisFrame;
|
||||
|
||||
if (shootInput)
|
||||
{
|
||||
FaceAimTarget(0.6f);
|
||||
TryShoot();
|
||||
}
|
||||
|
||||
// 5. Перезарядка (Клавиша R)
|
||||
// 6. Перезарядка (Клавиша R)
|
||||
if (Keyboard.current.rKey.wasPressedThisFrame)
|
||||
{
|
||||
TryStartReload();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Активирует быстрый и плавный поворот персонажа к направлению прицела камеры (перекрестия)
|
||||
/// и активирует стрейф-режим перемещения через PlayerMovement.
|
||||
/// </summary>
|
||||
public void FaceAimTarget(float duration = 0.5f)
|
||||
{
|
||||
PlayerMovement movement = GetComponent<PlayerMovement>();
|
||||
if (movement != null)
|
||||
{
|
||||
movement.SnapToAim(duration);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Переключение взятия/убирания оружия
|
||||
/// </summary>
|
||||
@@ -256,6 +276,9 @@ public class PlayerGun : MonoBehaviour
|
||||
|
||||
private void ExecuteShot()
|
||||
{
|
||||
// Поворачиваем персонажа лицом к прицелу перед вычислением траектории выстрела
|
||||
FaceAimTarget(0.6f);
|
||||
|
||||
// Звук выстрела
|
||||
if (audioSource != null && shootSound != null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user