private GameObject DetachObject() { GameObject dropedObject = carried.gameObject; carried.Dropped(); carried = null; return(dropedObject); }
public static Carried PickUpObject(GameObject toCarry, Transform toFollow, Vector2 offset) { Carried toRet = toCarry.AddComponent <Carried>(); toRet.ObjectPickedUp(); toRet.transform.SetParent(toFollow); toRet.transform.localPosition = offset; return(toRet); }
// Use this for initialization void Start() { levelManagement = FindObjectOfType <LevelManagement>(); gaurdMovement = FindObjectOfType <GaurdMovement>(); FollowCursor = FindObjectOfType <followCursor>(); winLose = FindObjectOfType <WinLoseScript>(); carried = FindObjectOfType <Carried>(); speed = moveSpeed; }
public static Carried PickUpObject(GameObject toCarry, Transform toFollow) { Carried carried = toCarry.AddComponent <Carried>(); carried.PickedUp(); carried.transform.SetParent(toFollow); carried.transform.localPosition = new Vector2(.4f, .4f); carried.transform.localRotation = Quaternion.Euler(0, 0, 0); return(carried); }
//Would be better if when we pickedup an object, we attached a "carried" script to it, that way //reseting back to the proper values is easier private void PickupObject(GameObject toPickUp) { carryingObject = Carried.PickUpObject(toPickUp, transform, localHandPos); //toPickUp.transform.SetParent(transform); //toPickUp.transform.localPosition = localHandPos; //carryingObject = toPickUp; //Collider2D coli = toPickUp.GetComponent<Collider2D>(); //Rigidbody2D rb = toPickUp.GetComponent<Rigidbody2D>(); //if(coli) coli.enabled = false; //if (rb) rb.bodyType = RigidbodyType2D.Kinematic; //isCarrying = true; }
//Would be better if there was an "attached" and "deattached" script on object, simpler to remove //and reset things back to original, here we assume the rigidbody should be dynamic... dangerous private GameObject DeattachCarryingItem() { //GameObject toRet = carryingObject; //Collider2D coli = toRet.GetComponent<Collider2D>(); //Rigidbody2D rb = toRet.GetComponent<Rigidbody2D>(); //if (coli) coli.enabled = true; //if (rb) rb.bodyType = RigidbodyType2D.Dynamic; //isCarrying = false; //carryingObject.transform.SetParent(null); //This is bad, what if it belonged to a parent group? //carryingObject = null; //return toRet; GameObject toRet = carryingObject.gameObject; carryingObject.ObjectDropped(); carryingObject = null; return(toRet); }
public void UpdateSampleOwner(Carried carriedby) { this.CarriedBy = carriedby; }
private void PickupObject(GameObject go) { carried = Carried.PickUpObject(go, handTransform); }