Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using DG.Tweening;
- using UnityEngine;
- public class PlayerHands : MonoBehaviour
- {
- [SerializeField] private Transform _holderPoint;
- [SerializeField] private float _collectTime = 0.5f;
- [SerializeField] private float _boxSize = 1f;
- private float _lastMoveStart;
- private IItemContainer _currentContainer;
- public void StartCollectItems(IItemContainer container) => _currentContainer = container;
- public void StopCollect() => _currentContainer = null;
- private void Update()
- {
- if (_currentContainer == null)
- return;
- if (_currentContainer.Items.Count == 0)
- {
- StopCollect();
- return;
- }
- if (_lastMoveStart + _collectTime > Time.time)
- return;
- _lastMoveStart = Time.time;
- Transform item = _currentContainer.Items.Pop();
- item.SetParent(_holderPoint);
- Vector3 localPoint = _holderPoint.childCount * _boxSize * Vector3.up;
- item.DOLocalMove(localPoint, _collectTime);
- item.DOLocalRotateQuaternion(Quaternion.identity, _collectTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement