Module 6: Publishing a Shape in 3 Dimensions

This module builds directly on Module 5: Expanding to Multiple Topics. You will need to complete that module before performing this module. In this module we will be making changes to our topic, extending it to movement in 3 dimensions.

Step 1: Updating ShapeComms

Our classes need to be updated to allow for writing the data from our 3D shape.

  1. Within the project, add a new class to the ObjectDefs as follows:

public class Shape3D : Shape
    public int z;

2. Update all instances of Shape to Shape3D (except for the definition of the Shape class in ObjectDefs).

3. We will need to add some code to some functions in order to utilize this functionality.

    1. In ShapeComms, add the following line to the SetShapeData function after the y SetValue call.

data.SetValue("z", shape.z);

b. In ShapeComms, add the following line to the ParseShapes function after the y assignment.

z = (Int32)shape.Data.GetAnyValue("z"),

c. In ShapeManager, in the MoveShape function, update the new Vector3 call to include shape.z:

m_Shapes[shape.color].GetComponent<Rigidbody>().MovePosition(new Vector3(shape.x, shape.y, shape.z));

d. In ShapeManager, in the AddInstance function, update the new Vector3 call to include shape.z:

m_Shapes.Add(shape.color, Instantiate(m_ShapePrefab, new Vector3(shape.x, shape.y, shape.z), new Quaternion()));

Step 2: Test Against RTI Shapes Demo

Here we are using the RTI Shapes Demo shipped with RTI Connext to test our new application.

  1. Launch the RTI Shapes demo from the RTI Launcher.
  2. Publish to the Square, Triangle, and Circle topics in the RTI Shapes demo.
  3. Click OK to use the default settings.
  4. Run the Unity application. You should see shapes moving across the screen.

If a shape does not appear, check the debug log within Unity to see if there are any problems within your application. Common problems include a missing license or XML file, along with misspellings of references within the XML file.

Also make sure that you didn’t make any mistakes in the conversion process, for example not changing a Shape to a Shape3D.


From this application we have shown that the DDS part of a Unity application is rather straightforward. The key is to map the Data Model used for communication to Unity objects. Once the mapping is figured out the Unity configuration and DDS code can be done relatively easily.

More complex Unity models may require more interpretation and coding to match up with data coming across the wire, but this is no more difficult than when using other communications schemas with incomplete information. For example, if the wheel speed of a car is not provided it would need to be inferred from velocity information. The same goes for velocity or turn information if position is only provided.

Meta Information regarding the use of the information within the model is another important consideration. As seen in this example, the need to invert the y coordinate and the need to correctly interpret valid color strings both provided situations where implementation was not fully obvious within the data model. This meta information is essential in matching your Unity application to system requirements and expectations.

See Next Steps below.

This video covers Module 6.


Next Steps

Now that you have completed the Unity and Connext Case + Code tutorial, please visit the RTI Community to share your feedback, ask questions and show the world what you built with Unity and Connext.

The objects and scripts used within this project can be found here in GitHub.

This is only an introduction to this type of integration. You should also check out our Unreal Engine Case + Code, which works using the same data model and behavior as this tutorial. This provides a method for interoperation between the two platforms and the option for tailoring the appropriate game engine to different requirements and/or developer experience.

Visit our Modeling, Simulation & Training web page to learn more about using RTI Connext DDS in simulation environments.