using UnityEngine; public class StockObject : MonoBehaviour { public StockInfo info; [SerializeField] float moveSpeed; public bool isPlaced; public Rigidbody theRB; private Collider theCol; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { TryGetComponent(out theRB); TryGetComponent(out theCol); } // Update is called once per frame void Update() { if(isPlaced) { transform.localPosition = Vector3.MoveTowards(transform.localPosition, Vector3.zero, moveSpeed * Time.deltaTime); transform.localRotation = Quaternion.Slerp(transform.localRotation, Quaternion.identity, moveSpeed * Time.deltaTime); } } public void Pickup() { theRB.isKinematic = true; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; isPlaced = false; theCol.enabled = false; } public void MakePlaced() { theRB.isKinematic = true; isPlaced = true; theCol.enabled = false; } public void Release() { transform.SetParent(null); theRB.isKinematic = false; theCol.enabled = true; } }