using System.Collections; using System.Collections.Generic; using UnityEngine; public class Pickable : MonoBehaviour { public Rigidbody rb; public Transform handlingPoint; public bool isGrabbing; void OnValidate(){ if(handlingPoint == null){ handlingPoint = transform; } if(rb == null){ rb = GetComponent(); } } void Start() { ogParent = transform.parent; } // Update is called once per frame void Update() { } Transform ogParent; public void Grab(){ rb.isKinematic=true; isGrabbing=true; transform.localRotation = new Quaternion(0,0,0,0); transform.parent = ItemGrabber.instance.holdingPoint; transform.localPosition = transform.position - handlingPoint.position; } public void LetGo(Vector3 vel){ isGrabbing = false; transform.parent = ogParent; rb.isKinematic=false; rb.AddForce(vel * 100, ForceMode.VelocityChange); } }