Dynamic Objects
Last updated
Last updated
To make an object dynamic (such as a door, drawer, lever, or valve), add a Dynamic Object component to the object.
Select the object dynamic type by clicking on the icons located at the top of the component.
Choose the Interact Type for the dynamic object, which can be either Dynamic, Mouse, or Animation type. Once you've selected the Interact Type, the References section will change, requiring you to assign all the necessary references to ensure the dynamic object works properly.
Make sure that the Pivot Mode is set to Pivot and Pivot Rotation to Local. If this will be set incorrectly, a prompt will appear.
To configure a dynamic door, begin by setting the Open Limits, Hinge, and Forward Axis.
Open Limits is actually an angle how the door should open. Rotate the door to its open position, note the hinge value, and update the Open Limits -> Max limit accordingly.
Rotate the door back to the closed position. Adjust the Target Hinge (the axis where the door pivots) and Target Forward (the axis along which the door mesh extends).
Make sure you have gizmos enabled, it will help you set up the dynamic object correctly.
In certain situations, if a door or custom openable model has a different pivot rotation, you can use axis mirroring to maintain positive axes. For instance, if an axis is set to X, toggling the mirror option will switch it to X_Negative, and vice versa.
The same principle applies to the Starting Angle, if the open position is reversed (e.g., -90 is open and 0 is closed), enabling mirroring will invert that angle as well.
If you select the Drawer dynamic type, you can determine the min/max open limits by copying the position from the corresponding axis, as demonstrated in the image below.
The process of configuring a switchable or rotatable dynamic type is similar to the previous steps.
To use a custom unlock dynamic script, create a script that implements the IDynamicUnlock interface. By doing so, you will be prompted to implement the OnTryUnlock() method, which will be called when you interact with the locked dynamic object. Here is a code snippet for a simple dynamic unlock script:
To use the dynamic unlock script, simply assign the reference to the script that implements IDynamicUnlock interface in the Unlock Script field.