Добавляю машины и настраиваю их
This commit is contained in:
1 parent
1c106ea853
commit
a8238ab49e
363 files changed
+54820
-687
No files matched your search
@@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerHands : MonoBehaviour
|
||||
{
|
||||
[Header("Точка удержания")]
|
||||
[Tooltip("Пустой дочерний объект перед камерой игрока")]
|
||||
[SerializeField] private Transform holdPoint;
|
||||
|
||||
[Header("Клавиши управления")]
|
||||
[SerializeField] private KeyCode dropKey = KeyCode.G;
|
||||
[SerializeField] private KeyCode throwKey = KeyCode.Mouse1; // Правая кнопка мыши
|
||||
[SerializeField] private float throwForce = 7f;
|
||||
|
||||
private CarPart currentPart;
|
||||
|
||||
public bool IsHolding => currentPart != null;
|
||||
public CarPart CurrentPart => currentPart;
|
||||
public Transform HoldPoint => holdPoint;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!IsHolding) return;
|
||||
|
||||
// Бросить под ноги
|
||||
if (Input.GetKeyDown(dropKey))
|
||||
{
|
||||
DropCurrentPart(Vector3.zero);
|
||||
}
|
||||
// Бросить вперед с силой
|
||||
else if (Input.GetKeyDown(throwKey))
|
||||
{
|
||||
Vector3 force = holdPoint.forward * throwForce;
|
||||
DropCurrentPart(force);
|
||||
}
|
||||
}
|
||||
|
||||
public void PickUp(CarPart part)
|
||||
{
|
||||
if (IsHolding)
|
||||
{
|
||||
// Если уже что-то держим — роняем старую деталь под ноги
|
||||
DropCurrentPart(Vector3.zero);
|
||||
}
|
||||
|
||||
currentPart = part;
|
||||
currentPart.OnPickedUp(holdPoint);
|
||||
}
|
||||
|
||||
public void DropCurrentPart(Vector3 impulse)
|
||||
{
|
||||
if (!IsHolding) return;
|
||||
|
||||
CarPart dropped = currentPart;
|
||||
currentPart = null; // Освобождаем руки
|
||||
dropped.OnDropped(impulse);
|
||||
}
|
||||
|
||||
public void ClearHandAfterInstall()
|
||||
{
|
||||
currentPart = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 962f82a2c1ed4c7288b8c49e0a91b607
|
||||
timeCreated: 1790290101
|
||||
@@ -13,7 +13,7 @@ public class PlayerInteractor : MonoBehaviour
|
||||
// Пускаем луч из центра экрана
|
||||
Ray ray = new Ray(transform.position, transform.forward);
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, interactRange, interactableLayer))
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, interactRange, interactableLayer, QueryTriggerInteraction.Collide))
|
||||
{
|
||||
IInteractable interactable = hit.collider.GetComponentInParent<IInteractable>();
|
||||
|
||||
|
||||
Reference in new issue
Block a user