I am trying to create an interactive environment in Omniverse Create where my character would walk around and select certain objects. I am planning to implement this as an OmniGraph with some custom nodes. I have the following questions:
Is it possible to programmatically create a cross-hair in the middle on the screen for every frame?
How can I programmatically detect if objects are hovered when using the Character Controller?
How can I programmatically select an object when using the Character Controller?
Can I use the UI nodes from OmniGraph when using the Character Controller?
Can I set the cursor position to the center of the viewport?
So far I haven’t found any way of using both the Character Controller and the UI capabilities of OmniGraph inside the viewport.
In the next version you will find a new Character Controller OmniGraph node and a demo that showcases how to use it (under Character Controller/Action Graph in the Window/Simulation/Physics/Demo Scenes). As far as using the Character Controller using Python, there’s already a demo called “Arena” (will be renamed to just “Python” to make a clear disctinction from the Action Graph demo).
The “Arena” demo (CharacterControllerDemo.py in omni.physx.cct) also shows how to create a crosshair and there’s also a raycasting code using get_physx_scene_query_interface().raycast_closest that enables pushing a cube around when mouse is pressed while it’s under the crosshair. You can reuse that to select a prim that you point at instead, the selection is changed with omni.usd.get_context().set_selected_prim_paths(path_list, True).
I am not that well versed in Action Graph and also it’s evolving very quickly, so I am unsure about the interaction with UI nodes, however in general when in first person mode the Character Controller code takes over the mouse and there’s currently no way how to turn it off during runtime (except turning off first person mode for that character controller instance). The mouse centering, when first person mode is turned on, is done in Python using carb.windowing.acquire_windowing_interface().set_cursor_position.
In general checking out the implementation of CharacterController.setup_controls in utils.py from the omni.physx.cct extension might be helpful/interesting too.