📤Dispenser Point
Dispenser points allow grabbables to be dispensed in predetermined points or areas. A dispenser point will take an object in the scene or a prefab and will allow the player to take copies of that item from the point
Dispenser will hide the given source object and dispense copies. If destroy on reset is disabled the dispenser will automatically pool the dispensed objects, this is more optimized but will not always give the desired results, for example: when dispensing ammo for a gun turning destroy on reset off will cause the already used ammo to be dispensed once the max copies are reached instead of a brand new fully copy

Dispenser Settings
Dispense ObjectThe object to be copied and dispensedMax CopiesThe maximum copies allowed to exist from this dispenser before they are destroyed or pooledReset DelayTime in seconds before the next dispense appearsDisable BodyWhether or not objects placed in the dispense point should be set to kinematic on placed or notIs KinematicWhether or not objects placed in the dispense point should be set to kinematic on placed or notDestroy On ResetIf true the object will not be pooled and reset its position on reset it will be destroyed and a new copy will be placed. Less performant but important for things like ammo that should always respawn as new clips fullMax DistanceThe maximum distance a dispensed object can move from the point before the next object is dispensed
On Grab Dispense called when the dispensed object is grabbed
On Dispense called when a new dispensed item is spawned
Programming Info
Connect Dispenser Point events through a custom script
using UnityEngine;
using Autohand;
public class DispenserEventTemplate : MonoBehaviour {
public DispenserPoint dispenserPoint;
void OnEnable() {
dispenserPoint.OnGrabDispenseEvent+= OnGrabDispense;
dispenserPoint.OnDispenseEvent+= OnDispenseEvent;
}
private void OnDisable() {
dispenserPoint.OnGrabDispenseEvent -= OnGrabDispense;
dispenserPoint.OnDispenseEvent -= OnDispenseEvent;
}
public void OnGrabDispense(DispenserPoint point, Grabbable grab) {
//Stuff happens when the dispensed grabbbale is grabbed
}
public void OnDispenseEvent(DispenserPoint point, Grabbable grab) {
//Stuff happens when a new object is dispensed, references the new grabbable that appears in a dispenser
}
}Last updated