Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rumble Manager and Demo #557

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

lunarcloud
Copy link
Contributor

@lunarcloud lunarcloud commented Oct 31, 2023

Supercedes #250 - previous Godot 3 era implementation.
Makes it possible to add rumble to standard functions like #191 suggests (adds a couple)

image

@lunarcloud
Copy link
Contributor Author

GDLint failure is due to static variables not yet being implemented ( Scony/godot-gdscript-toolkit#242 )

@lunarcloud
Copy link
Contributor Author

lunarcloud commented Oct 31, 2023

FYI - I didn't intend to change anything in assets or hands - godot just forced that on me.

@Malcolmnixon
Copy link
Collaborator

Malcolmnixon commented Oct 31, 2023 via email

@lunarcloud lunarcloud force-pushed the feature/191_godot4_rumble branch 4 times, most recently from ca946cd to 2f3a343 Compare October 31, 2023 21:06
@lunarcloud
Copy link
Contributor Author

Okay, fixed the extraneous changes, pre-squashed and rebased

@lunarcloud lunarcloud force-pushed the feature/191_godot4_rumble branch 3 times, most recently from b55821a to fe98d2c Compare November 1, 2023 00:23
@lunarcloud lunarcloud marked this pull request as draft November 1, 2023 00:38
@lunarcloud
Copy link
Contributor Author

Going to add doc comments and deal with @Malcolmnixon 's suggestions

@lunarcloud lunarcloud force-pushed the feature/191_godot4_rumble branch 7 times, most recently from 3b823ec to b83f990 Compare November 1, 2023 02:50
@lunarcloud lunarcloud marked this pull request as ready for review November 1, 2023 02:52
@lunarcloud
Copy link
Contributor Author

We cleaned up the documentation, added poke and button rumble examples, added a "hand aware rumbler" helper

@lunarcloud
Copy link
Contributor Author

I think there's an argument to be made that the rumbler not the rumble events definition should be in charge of defining which hand (or both) gets rumbled.
But this all works and is fun as-is, so I might stop meddling until after a review from Bastion

@Malcolmnixon
Copy link
Collaborator

I was able to test out the gdlint fix by installing from git-hash using:

pip3 install git+https://github.com/Scony/godot-gdscript-toolkit.git@ad525088fc3d4633a8577d37da1def8addfb32f4

The result was:

.\rumble\rumble_manager.gd:37: Error: Definition out of order in None (class-definitions-order)
.\rumble\rumble_manager.gd:40: Error: Definition out of order in None (class-definitions-order)
.\rumble\rumble_manager.gd:44: Error: Definition out of order in None (class-definitions-order)
.\rumble\rumble_manager.gd:47: Error: Definition out of order in None (class-definitions-order)
Failure: 4 problems found

The fix is to move the static var to be the last var defined - just before the is_xr_class() function.

@lunarcloud
Copy link
Contributor Author

I was able to [...]
The fix is to[...]

Yup, just re-ran it myself and fixed that issue.

@lunarcloud lunarcloud force-pushed the feature/191_godot4_rumble branch 2 times, most recently from 169bde4 to 1bdf7ef Compare December 1, 2023 21:59
@lunarcloud lunarcloud marked this pull request as draft December 1, 2023 22:18
@lunarcloud lunarcloud force-pushed the feature/191_godot4_rumble branch 3 times, most recently from 7f5b04a to e2e051e Compare December 1, 2023 22:25
@lunarcloud lunarcloud marked this pull request as ready for review December 1, 2023 22:32
@lunarcloud
Copy link
Contributor Author

Rebased on top of the latest changes (and the gdlint update is now live)

@lunarcloud
Copy link
Contributor Author

I discussed this with @Malcolmnixon in person, but... I'm feeling like the Rumble Event resources shouldn't include the intended hand. We found that in practice, 90% of things want to rumble EVERYTHING or a specific hand (or head (XRCamera?), chest, other XRNode3d)

@lunarcloud lunarcloud force-pushed the feature/191_godot4_rumble branch 3 times, most recently from d5bdfa4 to 31b6b65 Compare December 18, 2023 03:26
@lunarcloud
Copy link
Contributor Author

I discussed this with @Malcolmnixon in person, but... I'm feeling like the Rumble Event resources shouldn't include the intended hand. We found that in practice, 90% of things want to rumble EVERYTHING or a specific hand (or head (XRCamera?), chest, other XRNode3d)

Okay. No more hand enum inside events. Events are just duration/pausable/magnitude. tracker that gets rumbled is just going to be the XRInterface tracker string, which can be grabbed from any XRNode3D (like left/right XRController3D). So if you really want to rumble some special gear, go wild.

@DigitalN8m4r3
Copy link
Contributor

@BastiaanOlij holy Macaroni this is still not merged

@lunarcloud
Copy link
Contributor Author

Sorry I haven't made the meetings to try and push this feature's inclusion. Let me know if there's any issues needing attention. It's the last feature I feel is missing for my XR usage.

@BastiaanOlij
Copy link
Member

Indeed, long overdue to get his merged and I am sorry it's taking me this long to have an in depth look. That said, more people really need to have a look at this and see if they agree with this approach and leave feedback on this PR. We can't just merge this because we need a rumble approach. People need to understand it.

In broad strokes I really like this approach, the rumble manager is a neat way to combine rumbles from different sources and potentially future proofs this. It is really hard to predict what's in the future here, especially because I don't think the industry knows yet, but we can look at what's out there already in the XR space, both in more advanced haptics on controllers and things like haptic vests.

My current assumptions here is that we're going to start seeing haptic solutions that work akin to spatial audio. Something in game triggers a haptic pulse at a given location, feedback from pulling a trigger, feedback from a stick you're holding hitting surface, feedback from something hitting the body in a certain location, feedback from a pulse happening near the player. This information is sent to the rumble manager, the rumble manager detects which haptic feedback devices are in range of the pulse, and triggers various haptic feedback events on those devices.

That at this point in time our solution is more directly structured around the output, that's a fine starting point. We're not at this future point yet and there is no certainty that is where this will head. But we're at the right base.

Technically there are two things we need to change in the approach IMHO for this to be mergeable.

  1. The singleton implementation is flawed. When you switch between two scenes, there will briefly be two rumble managers, with the outgoing one remaining the singleton breaking the system. We can change this in three ways:
    a. We can make this a true singleton and autoload the script globally. But this causes problems if the user doesn't add the autoload script. That is something that can be tested on the rumbler logic.
    b. Don't use a singleton but take the same pattern as with the PlayerBody, e.g. use our lookup helper functions to find the rumble manager attached to the XROrigin3D. But this may not be an option when the rumble originates from the environment.
    c. Add the manager to a list when added to the scene tree, remove it from the list when it's removed, have the last added entry in the list be the singleton, keep all data in static variables so they are shared amongst the managers and/or add gates so managers ignore calls when they are not the active singleton.

  2. This is probably inherited from the Godot 3 days but we can't hardcode the actions. This needs to be usable with customised action maps.
    a. I would change rumble_on_button.gd to work for a single event. I would thus also rename it to rumble_on_action.gd, have one property for the action name, have one property for the rumble event. Now it can work with any action, including trigger, grip, etc. When you want to trigger rumbles on multiple buttons, you just add multiple child nodes to the controller, one for each action. I would also add an enabled property (default on), so things can be enabled contextually.
    b. HAPTIC_ACTION shouldn't be hardcoded. We don't currently have a way to interrogate the loaded action map, I really should make something for that, because ideally we'd get a list of active haptic actions per controller from the system. That will have to wait until we redo the action map as a more global system. For now I think it's enough for this to just be a property on the manager. We can look at enhancing this when multiple haptic actions become a thing in a later update.

I think there is much more we can do in future updates, but I think if we handle the above, we have a solid foundation.

@Malcolmnixon
Copy link
Collaborator

Touch-rumbling appears to have been broken with the last round of changes. What's going on is that the XRToolsPoke node has grown new pressed and released events which are fired when the poke touches and releases an object... however these events only report the object being poked.

The pressed event is wired to the XRToolsRumbler.rumble_hand method; which tries to find the hand associated with the node provided... but the node is the object being poked - and has no relationship to the hand to rumble.

One option would be to add an XRToolsRumbler.rumble_pointer which takes an XRToolsPointerEvent. This is also fired from XRToolsPoke and contains the pointer and target. The rumbler can use the pointer to track down which hand to rumble. This would also allow it to work with laser-pointers if desired.

@lunarcloud lunarcloud force-pushed the feature/191_godot4_rumble branch 4 times, most recently from 941d07b to 15feeb0 Compare May 25, 2024 01:11
@lunarcloud
Copy link
Contributor Author

lunarcloud commented May 25, 2024

@Malcolmnixon we worked together to rebase and then un-break.

@BastiaanOlij

  1. Addressed via solution a.
  2. unaddressed, but it makes sense to fix

@Malcolmnixon
Copy link
Collaborator

Indeed - we'll want to address the 'haptic' action name at some point soon.

Copy link
Member

@BastiaanOlij BastiaanOlij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think this is ready to be merged and it can evolve from there. Sorry it took so long to get it over the line

@Malcolmnixon Malcolmnixon merged commit d080613 into GodotVR:master Jun 4, 2024
2 checks passed
@lunarcloud lunarcloud deleted the feature/191_godot4_rumble branch June 4, 2024 02:48
@zacharysarette
Copy link

LGTM, I think this is ready to be merged and it can evolve from there. Sorry it took so long to get it over the line

Nice! Now we're ready to RUMBLE!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants