public void getPushed(Vector2 direction, KinematicPlayer script) { currentState = state.PUSHED; // reduce collider size, so that adjacent tiles aren't accidently hit reduceColliderSize(); // check if we're inside a block. if we are, destroy ourselves RaycastHit2D[] results = new RaycastHit2D[8]; if (c2d.Cast(Vector2.one, rockFilter, results, 0) > 0) { HitDestroy(); } gameObject.layer = projectileLayer; rb2d.bodyType = RigidbodyType2D.Dynamic; rb2d.velocity = pushSpeed * direction; if (!owner) { owner = script; } c2d.isTrigger = false; timePushed = Time.time; if (attachedObject) { attachedObject.DestoryObject(); } }
public bool getGrabbed(KinematicPlayer script) { if (currentState != state.FIXED) { return(false); } gameObject.layer = noColLayer; currentState = state.HELD; rb2d.bodyType = RigidbodyType2D.Dynamic; owner = script; c2d.isTrigger = true; if (otherObject) { otherObject.DestoryObject(); } return(true); }