Receiving and Reacting to Messages
These converters provide UnityAction acting on other datatypes than string. When added through the Tools menu, a regular subscriber component will be attached to the selected gameobject along with the according converter component. Add desired actions in the converter component, rather than the subscriber. The following converters are currently available:
dynamic vs static
If you want to use values from the MQTT message in UnityActions, make sure to select members from the dynamic section of the action (see image for an example). In the example, if you select intensity in the dynamic section it will take the value from the MQTT subscriber. If you select float intensity in the static section, you can define a fixed value to be used, no matter what the message payload is.
SubscriberFloatConverter
Add actions that set floats in gameobjects. For example light.intensity, audioSource volume, etc.
SubscriberIntConverter
Add actions that set integers in gameobjects. Potentially used to have objects switch layers and such.
Author's remark: To be perfectly honest, I never used it, it just felt mandatory to implement it. If you find a use-case, please contact me and I will add it to the manual.
SubscriberColorConverter
Add actions that react to color payloads and set color tints, light color, or material color (Caution: Changing assets like materials in Editor is permanent)
SubscriberQuaternionConverter
Add actions that set a Quaternion. This is mainly used to set rotations on transforms.
SubscriberVector3Converter
Add actions that set Vector3s. This is extremely versatile and can be used to change position, scale, rigidbody velocity, navmesh agent destination, and many more things.
Conditional Subscriber
These components will provide you with an easy way for action branching. All conditional subscribers will provide you with a comparison option (more on that in the component specific part) and two UnityActions.
- True Action (executed whenever the condition is met)
- False Action (executed when the condition is not met) It is totally fine to use only one of the two.
Compare String (ConditionalSubscriber)
This component compares a given string with incoming MQTT messages and Invokes all the UnityActions in TrueAction if it matches and those in FalseAction if it doesn't.
Add menu: Tools->SmoothMQTT->Receive->Compare String Subscriber
Compare float (ConditionalFloatSubscriber)
Compare incoming MQTT messages interpreted as float with a value or even a range. In the field comparison operator you can select either typical comparators like: "=, !=, <, <=, >, >=" to compare with the value in CompareValue. WithinRange and OutsideRange allows to compare with the range defined by CompareValue and AdditionalRangeCompareValue. (Attention: a period should be used as decimal point)
Add menu: Tools->SmoothMQTT->Receive->Compare Float Subscriber