Custom Build

If you have a specific need for how elements are positioned during assembly you can provide your own Custom Build method for Artificer to use for placing the elements. To use this create your own class derived from the CustomBuild virtual class and override the Place method with your own code. Then in the inspector select the object that script is attached to in the Custom Build section of the Build Options. Your method will then be called instead of the Artificer build styles.

Custom Build Class

using UnityEngine;

namespace Artifice
{
	public class CustomBuild : MonoBehaviour
	{
		public virtual void Place(MeshElement me, float alpha, int index, out Matrix4x4 tm, out Color col)
		{
			Vector3 dir = (me.center - me.origin).normalized;
			Vector3 p = (dir * me.buildDist * (1.0f - alpha));

			tm = Matrix4x4.TRS(p, Quaternion.identity, Vector3.one);
			col = Color.white;
		}
	}
}

Place

This called for every element it is up to your to return the Matrix4x4 tm for the position of the element . The color option is not currently used.

me - The MeshElement that is being positioned

alpha - How far along its build animation it currently is.

index - The element id

tm - This is the transform matrix of the element being moved

col - Not used

The default place method shows a basic position bit of code. It just does a simple lerp of the object calculating the direction and using the elements builddist value to get the final position. No rotation or scaling is applied.

Last updated