GameObject
Functions
SetActive
function GameObject.SetActive((bool)Activate or Deactivate)
Parameter | Type | Description |
---|---|---|
Activate or Deactivate | bool |
Desired activation status. |
GameObject.SetActive
Activates/Deactivates the object based on the bool parameter value
Example
gameObject.SetActive(true)
IsActive
function GameObject.IsActive()
GameObject.IsActive
Returns true if the object is active in the hierarchy
Example
gameObject.IsActive()
Clone
function GameObject.Clone()
GameObject.Clone
Clones the gameobject and returns the clone.
Example
gameObject.Clone()
AddInventory
function GameObject.AddInventory((optional string)Inventory Name , (optional int)NumberOfSlots, (optional bool)playerInventory, (optional string)usableLocked, (optional bool)onlyReceive)
Parameter | Type | Description |
---|---|---|
Inventory Name | optional string |
Name of this inventory. Defaults to 'Inventory' |
NumberOfSlots | optional int |
Number of slots this inventory will have. Defaults to 1. |
playerInventory | optional bool |
If true this sets this inventory as owned by the player. It's usually true unless it's a npc shop or a loot chest. Defaults to true. |
usableLocked | optional string |
If this parameter isn't empty this inventory will only be able to receive items that have that string as its usable type. Defaults to empty. |
onlyReceive | optional bool |
If true this inventory will only be able to receive items, never take them out. Useful for collections like the museum. Defaults to false |
GameObject.AddInventory
Adds an inventory to this gameobject reference.
Example
gameObject.AddInventory()
AddCraftingMachine
function GameObject.AddCraftingMachine()
GameObject.AddCraftingMachine
Makes this gameobject a Crafting Machine. If you want this crafting machine to be able to craft items over time make sure to add an inventory to this gameobject and pass it as a parameter. If it works over time also make sure to set it as autoload when creating the item's json
MakePlanter
function GameObject.MakePlanter((Vector3)Soil Position)
Parameter | Type | Description |
---|---|---|
Soil Position | Vector3 |
Position of the soil in the planter, local space. |
GameObject.MakePlanter
Makes the object a planter. Make sure to only use it in Buildable objects.
Example
gameObject.MakePlanter()
CreateSphereCollisions
function GameObject.CreateSphereCollisions((optional float)Radius)
Parameter | Type | Description |
---|---|---|
Radius | optional float |
Radius of the sphere collider. Defaults to 1. |
GameObject.CreateSphereCollisions
Adds a sphere collider to this gameobject.
Example
gameObject.CreateSphereCollisions()
AddDebugSphere
function GameObject.AddDebugSphere()
GameObject.AddDebugSphere
Adds a debug sphere to this game object reference.
Example
gameObject.AddDebugSphere()
AddModel
function GameObject.AddModel((string)Model Name , (Vector3)Local Position, (Vector3)Local Rotation, (Vector3)Local Scale)
Parameter | Type | Description |
---|---|---|
Model Name | string |
Model filename without extension |
Local Position | Vector3 |
Local Position relative to this gameobject |
Local Rotation | Vector3 |
Local Rotation relative to this gameobject |
Local Scale | Vector3 |
Local Scale relative to this gameobject |
GameObject.AddModel
Adds a new model to this gameobject. Make sure the model is in the models folder.
Example
gameObject.AddModel("Test")
Recycle
function GameObject.Recycle((optional float)Delay)
Parameter | Type | Description |
---|---|---|
Delay | optional float |
Defaults to 0, if it's different than 0 it will wait that amount of seconds before actually recycling the object. |
GameObject.Recycle
This will disable this GameObject and register it back into the ObjectPool so it can be spawned again when a similar object is needed. If you have a reference to this transform you should get rid of it after calling recycle.
Example
gameObject.Recycle()
Destroy
function GameObject.Destroy((optional float)Delay)
Parameter | Type | Description |
---|---|---|
Delay | optional float |
Defaults to 0, if it's different than 0 it will wait that amount of seconds before actually destroying the object. |
GameObject.Destroy
This will destroy this GameObject. It will no longer exist.
Example
gameObject.Destroy()