Methods
Below you will the various public methods that allow you to control the assembly and dismantling of your artificer objects from your own scripts.
RandomValue
public float RandomValue()Returns a random float value between 0 and 1 using the Artificer random number generator and not the Unity Random.
RandomRange
public float RandomRange(float min, float max)Returns a random float value between the min and max values using the Artificer random number generator.
RandomRange
public int RandomRange(int min, int max)Returns a random int value between the min and max values using the Artificer random number generator.
ReadyToBuild
public bool ReadyToBuild()Will return true if the Artificer object is in a state that is is ready to build. So the object is currently not visible and is not in any current build or dismantle animation state.
ReadyToDismantle
public bool ReadyToDismantle()Will return true if the Artificer is in a state that it is ready to dismantle. So the object is currently fully built and not playing any builr or dismantle animation.
StartBuild
Will start the Artificer object building. It is best to use the ReadyToBuild method above to first check that it is OK to start a build animation running.
SetBuilt
Will set the Artificer object instantly to its fully built state.
SetDismantled
Will set the Artificer object to its fully dismantled state.
StartDismantle
Will start the Artificer object dismantling. It is best to use the ReadyToDismantle method above to first check that it is OK to start a dismantle animation running.
BuildData
Will do a rebuild of the animation data. You can call this if you make any runtime changes to the Artificer values and need to rebuild the animation data. This can be a slow process if you have a very complex set of objects. It is best to pre bake your data to multiple different BuildData files and then just swap between them.
StartPartBuild
It may be the case that you want to control the building of an object from script instead of it all building in one go. You can do this with the Part Build option. This method will start a build that will be controlled by further calls to BuildParts. You can control how much of the object is built per call and how quickly those parts are added.
steps - The initial build to step, this is a normalised value between 0 and 1. If you set this to say 0.25 then a quarter of the object will be built then the build process will stop. If you wanted to build your object in say 10 steps then use a value of 0.1 and so on.
amount - The amount or speed of the build that will happen. A value of 1 will build all the parts at the normal build speed for the object. A value of 0.5 will build them at half the speed. You can use values above 1 if you like.
BuildParts
If you have started a part build then you can call this method to add to the build as required. The values passed in work the same as the StartBuild params.
steps - The initial build to step, this is a normalised value between 0 and 1. If you set this to say 0.25 then a quarter of the object will be built then the build process will stop. If you wanted to build your object in say 10 steps then use a value of 0.1 and so on.
amount - The amount or speed of the build that will happen. A value of 1 will build all the parts at the normal build speed for the object. A value of 0.5 will build them at half the speed. You can use values above 1 if you like.
IsBuilt
This will return true if the build animation has finished.
IsDismantled
Will return true if the dismantle animation has finished.
IsBuilding
This will return true if the the object is currently being built.
IsDismantling
This will return true if the object is currently dismantling.
ShowUnBuiltElements
You many need to show what is going to be built in say a ghosted material so you can see what is about to be built etc. This method will draw any unbuilt elements of the object with the material passed in and will optionally draw any element that is in the process of being placed in the same or another material.
unbuiltmat - The material to use to render the unbuilt elements in the mesh.
includePlacing - If you would like to render any element that is in the process of being placed set this to true.
placingMat - The material to use for rendering elements that are in the process of being placed, if null the unbuiltmat will be used instead.
ContinueBuild
If you have used the SetBuiltLevel method to build the object to a certain level then you can use this method to continue the building to completion.
PauseBuild
You can pause the building process at any point by passing true to this method, and you can unpause it by passing false.
SetBuiltLevel
You may need to set the current build level instantly to a certain position, for example loading a saved game and a building it only partly built. Calling this method will instantly build the object to the normalized alpha value, so a value of 0.25f would quarter built the object.
alpha - The amount to build the object to, 0 to 1, 0 is unbuilt and 1 is fully built.
IsPaused
Will return true if the build is in a paused state, and false if not.
Last updated