Interactable Final Placement Prefab Constructor

This script is attached to a prefab that’s duplicated from the interactable item and it serves the role of the final placement. The way it works is that it has a collider and when the collision registers with the other gameobject it observes their transform. It their difference is below a specified margin (the rotations match to a certain point), the collision gets accepted.

This prefab will -on start- have its renderers disabled and it will be awaiting collision. When the collision succeeds, it detaches the interactable prefab from the user’s hands, it translates it to the position (and rotates it) the final prefab is. When they are at the same position the prefab that the user had at hand gets destroyed and the final prefab enables its renderers.

When all of this it’s done the final behavior of this prefab is called (e.g. some specific animation after the prefab is placed) and it triggers the Event Manager for the Action completion.

Prefab Creation Requirements

  1. Rigidbody

  2. Trigger Colliders

  3. Prefal Lerb Placement script

For now, this script does not search for animator in the gameobjects components, but an animation component. To be able for the animation to play by itself without the animator it must be legacy supported (explained how in image below)

Interactable Final Placement

Prefab Lerp Placement

Everything explained above is the works of this script, PrefabLerpPlacement. That constructor only observes if the prefab has this script attached. This script can be used on its own anywhere.

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.

Lerp Seconds Play

float

When collision is accepted, the prefab at hand gets detached and transforms to the correct position of the one placed. This variable sets for how long that transition will last.

Translate Speed Mul

float

Translation speed multiplier.

Rotate Speed Mul

float

Rotational speed multiplier.

Bypass Is Attached Check

Boolean

Keep false! It should be true only for prefabs that mid-action are children to another gameobject.

Allow Renderer Manipulation

Boolean

This gameobject has its renderers disabled until it replaces the interactable prefab (after collision acceptance). Set to false if its renderers are desired to be permanently on.

Interactable Prefabs

list of gameobjects

Insert here all the gameobjects that this prefab is going to await collision with.

Holograms

list of gameobjects

Each action can have gameobjects that serve the role of visual aid for the user to understand how to perform the Action. Since this Action will have to do with inserting something, these helpful holograms need to be destroyed after the user just correctly placed the gameobject. Insert here all the prefabs that help the user understand this particular action. When the interactable gameobject is placed, this script will destroy all the inserted holograms.