/* * Rammasse l'objet en parametre. * Si le personnage tient deja un objet, ne fait rien * -> bool : true si l'objet a ete ramasse, sinon false */ public bool pickBigObject(Rigidbody2D obj) { if (bigObj) { return(false); } bigObj = obj; obj.BroadcastMessage("OnPickup", SendMessageOptions.DontRequireReceiver); bigObjOldState = bigObj.bodyType; bigObj.bodyType = RigidbodyType2D.Kinematic; bigObjOldLayer = obj.gameObject.layer; obj.gameObject.layer = gameObject.layer; return(true); }
public bool dropBigObject(out Rigidbody2D obj, out Transform dropPos) { dropPos = dropPosition; if (!bigObj) { obj = null; return(false); } obj = bigObj; obj.bodyType = bigObjOldState; obj.gameObject.layer = bigObjOldLayer; obj.BroadcastMessage("OnDrop", SendMessageOptions.DontRequireReceiver); bigObj = null; return(true); }