Skip to main content

FakePickup

A class in Root.Township, the global namespace.

Stand-in interactable that takes over a pickup's grips while that pickup is locked in place. DiggingImpactor uses it while a shovel is stuck in the ground.

Constructors​

MemberWhat it is
FakePickup()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private Rigidbody cachedRigidbodyThis object's rigidbody, which hand joints connect to.
private FixedJoint fixedJointJoint holding the target pickup to this object while attached.
private Dictionary<Interactor, GrabPointParameters> interactorToGrabPointGrab point each hand used, so it can be restored on the real pickup when detaching.
private static Logger loggerNLog logger for this class.
private Pickup targetPickupThe real pickup this object stands in for.

Properties​

MemberWhat it is
Dictionary<Interactor, Joint> Joints { get; }Fixed joints from each hand holding this object.

Events​

MemberWhat it is
event Action<Interactor> FakeInteractionEndedRaised when a hand lets go of the fake pickup.
event Action<Interactor> FakeInteractionStartedRaised when a hand grabs the fake pickup.

Methods​

MemberWhat it is
void Attach()Moves the target pickup's hands onto this object, freezes the pickup and joins it here with a fixed joint.
void Dettach()Undoes Attach: hands the grips back to the target pickup, unfreezes it and removes the fixed joint.
override void FinishInteraction(Interactor interactor)Stops the grip animation, removes the hand's joint and fires FakeInteractionEnded.
override void Interact(Interactor interactor)Grabs as if grabbing the target pickup (same grab point and hand placement), then joins the hand here.
void SetTargetPickup(Pickup pickup)Sets the pickup this object stands in for, removing itself from the old pickup's forward list.
3 private and internal methods
MemberWhat it is
private void CreateJoint(Interactor interactor)Adds a fixed joint from the hand's interaction point to this object and stores the grab offsets on the hand.
private void DestroyJoint(Interactor interactor)Removes the hand's joint, deferring the destroy during a physics overlap.
private bool EditorSetup()Editor helper: caches the rigidbody and disables the component.

Used in​

Members of other types that take, return or hold a FakePickup: