Interactable Final Placement Prefab Constructor¶
This script is attached to an actor that’s duplicated from the interactable item and it serves the role of the final placement. The way it works is that it has an overlap collider and when the collision registers with the other interactable actor it observes their transform. If their transform difference is below a specified margin (the rotations match to a certain point), the collision gets accepted and the action performs.
This actor will -on start- have all its renderers disabled and it will be awaiting an overlap event. When the collision succeeds, it detaches the interactable actor from the user’s hands, it translates it to the position (and rotates it) the final actor is. When they are at the same position the actor that the user had at hand gets destroyed and the final actor enables its renderers.
When all of this it’s done the final behavior of this actor is called (e.g. some specific animation after the actor is placed) and it triggers the Event Manager for the Action completion.
Prefab Creation Requirements¶
Overlap Colliders
Prefal Lerb Placement component
In the primitive component collision section
Generate Overlap Events
should be enabled, as well asCollision Enabled
should be set toQuery Only
Prefab Lerp Placement¶
Everything explained above is the works of this component, PrefabLerpPlacement. The constructor observes if the prefab has this component attached and it initializes it accordingly. This component can also be used on its own anywhere for lerping between two transforms using Dual Quaternions.
Variable Name |
Type |
Description |
---|---|---|
Max Angle Degree |
float |
Observes the rotations of the final placement and the interactable prefabs. If their difference in all three axis is less that this given margin, it accepts the collision. A value of zero means that any rotation is accepted. |
Lerp Difference |
float |
The max fault tolerance for the interpolation. A higher value leads to better performance but might lead to inaccurate results. |
Lerp Speed |
float |
Speed multiplier for how fast the interactable object should reach the final position/rotation. |
Interactable Prefabs |
list of actors |
Insert here all the actors that this prefab is going to await collision with. |