MBScript Variables
You can add Variables to the MBScript code which will then show in the Entity properties.

'OtherEntity' is a Entity Variable added. It then shows in the Entity Properties and can be set.
To add variables in MBScript, use the '+' button or the 'Add' dropdown at the top and select 'Add Variable'. You then select the variable type.
Variable types that have a value (like Number, Text, 'Entity', 'Entity Asset') can have a Default Value set (which will be the starting value when the MBScript is added to a Entity).
Variable Types
- Basic types like Bool (True/False), Number, Text
- All Assets types, like Entity Assets, Materials, Audioclips, etc
- Vectors, Range (with a min / max number)
- Entity: for a Entity in the world
Some variable types are made from multiple other types. If ‘Entity Component of X type’ is selected, you then select the type of Entity Component. This could be a component on a Entity like Transform / Health System, or could be another MBScript
Methods and ReturnMethods
Methods can be added that other scripts can call. They can have parameters set to pass values.
ReturnMethod are methods that return a value.
A 'Set to Red' method is given a Entity to set it's color to Red.
A 'Is Entity Red' method returns True if the Entity is red.
Event Variables
Added variables can also include new Events. Events can be called in the same script or in other entities.
Events are used to have any other MBScript code run when it's called - rather than just specific code like Methods.
If ‘Event(x)’ is selected, then an event variable with a parameter type is added (with the ‘x’ meaning you then select the parameter type). That way the Event can be called passing a value

Here every update it would call the 'Saw Entity' event for each Entity that was within 1m
Lists
When creating a variable type with a value there is a option to 'Create as List'.
If a variable is a List it'll show borders on the side of the icon.

A 'List of entities' variable is added. And on start it's set to all entities within 1 meter.
Then the 'Die' method is run on the first Entity in the list.
PlayTime Variable
PlayTime variables store the current 'play mode time': seconds since play mode started.
Each PlayTime variable also has a event added for when it's 'Lapsed'. Which can be a useful way to run code after a set amount of time / on a specific time loop

'Next Sound Effect' Play Time variable is added. The 'PlayAudio' method runs on Start, and when NextSoundEffect lapses - it then sets the 'NextSoundEffect' to the current time plus 3 seconds
Updated almost 2 years ago