Haptic feedback when a pointer enters the area of a 2dbutton in an XRToolsViewport2Dto3D

Godot Version

4.3

Question

I’m implementing functionality where, when the currently active pointer in my XRToolsViewport2Dto3D view (the _mouse in the viewport’s static body) enters a 2d button area, it triggers haptic feedback on the controller associated with the pointer similar to the way system menus work on meta quest.

I didn’t see a great way to find out the currently active pointer in a XRToolsViewport2DTo3D . I have two FunctionPointer objects in my scene, one nested under each controller. I ended up adding

func get_active_pointer() -> Node3D:
	return $StaticBody3D._mouse

to the XRToolsViewport2Dto3D code and then comparing the active_pointer in the viewport to my left and right controller pointers in order to know which one to vibrate

func is_right_hand_pointer_active() -> bool:
	var active_pointer = $LevelSelectMenu. get_active_pointer()
	return $XROrigin3D/RightHand/FunctionPointer == active_pointer

Anyway, wondering if I just missed a cleaner way. If not it seems like it could be a good addition for the usecase I describe.

Hmm, not of the top of my head, but I like the idea behind the feature. I’d need to give it some thought.

1 Like