Hello, I am building a vehicle and need a way to compare the values of multiple variables across multiple scripts at the same time (and plotted as a function of time).
The problem I experience is that I have no concise method to visualize the changes generated by an AI controller and see how it’s PID loops are making the vehicle respond by overshooting/undershooting.
Currently I use a simple method of adding [Range(-n,+n)] attributes in the inspector, and by watching and comparing the sliders in the inspector panel it makes things easier than watching a stream of numbers in the console moving at hypersonic velocity. However this is limited to the instantaneous values and has no temporal resolution. Also this only allows one gameobject at a time to be observed.
What I need is basic plotting of variables across multiple scripts.
And I don’t think Unity offers this by default, but I won’t let that deter my ambitions (much).
-
Are there any assets that offer simple plotting or other similar features?
-
Would making an in-game “plot gameobject” be a sensible option (eg. using a bunch of line renderes)?
-
I could see this being a very cumbersome task to build, maybe…
-
I am also familiar with Python and Matplotlib and really like the plots it offers.
-
How could I make the two languages/applications work together? I have used sockets in the past but find them tricky. Would having Unity continuously write .txt/.csv files while Python reads and plots them be a good approach?
-
Are there any other plotting programs that might be useful for this?
[SOLVED]
So I stayed up all night and just created a new tool for this task which uses Python and MatPlotLib to plot the values in realtime:
UPyPlot (Download from GitHub)
Unity Python Plotting - Script variables to realtime MatPlotLib visualization
It’s rather easy to use and works well (but is still very basic). For any value you wish to have plotted, all you must do is add a custom attribute where you declare that variable, then just run the PlotViewer.py file from Python while the game is running. That’s it!
At present the tool offers some configurability such as:

-
Precision - Number of decimal places for each value in the plot data file.
-
Interval - Rate in seconds which to update plot data file with new values.
-
Max Samples - Maximum lines/history that the plot file should contain.
[UPDATE]
I added an advanced plot viewer to the project that allows selecting between a single plot style where all lines are combined on a single axes and scale, and another where each line is on it’s own individual plot axes:
Hope this is useful for someone.


