Does control in spatial exist?

Is there a way to find out if a control exist in a spatial. I want to know via code if a spatial has a physics control(rigidbody). Some of my spatials have the control and some don’t. I want to sort through them on demand and find out which ones do and don’t.

Spatial.getControl(Class<? extends Control>) if doesn’t exist it returns null.

The solution posted by Riccardo is the standard solution.

A faster way is to save a reference like in an array of boolean and then access that array via the id of your Spatials.
You could also make a HashSet of Integer over the ids of your Spatial objects that have rigid body controls.
Or you make a HashSet of Spatial which would be even faster (don’t need to ask for the int id of your spatial then).
And you could also add a custom data of type boolean that will return true if rigid body is attached.
These things are more verbose but hopefully much faster (test it - it may be slower than I think).

But yes, you can use what Riccardo wrote and this is in one of the basic tutorials too…