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

Added support for different player "up" orientations. #305

Merged
merged 1 commit into from
Dec 24, 2022

Conversation

Malcolmnixon
Copy link
Collaborator

@Malcolmnixon Malcolmnixon commented Dec 23, 2022

This pull request allows for different "up" orientations for the player. The changes are:

  • Modify XRToolsPlayerBody to apply gravity/control based on the ARVROrigin up direction
  • Modify XRToolsPlayerBody to support orientation providers which control the player orientation
  • Added XRToolsOrientationGround provider to orient to the ground under the players feet
  • Added XRToolsOrientationArea provider to orient based on orient-control areas
  • Added XRToolsOrientAreaPath to orient the player along a path
  • Added XRToolsOrientAreaPoint to orient the player to a point
  • Added XRToolsOrientAreaUniform to orient the player in a uniform vector
  • Moved common code from movement and orientation providers to XRToolsPlayerProvider
  • Modify XRToolsMovementClimb to work in the players orientation
  • Modify XRToolsMovementFlight to work in the players orientation
  • Modify XRToolsMovementGlide to work in the players orientation
  • Added Origin Gravity demo scene
  • Added Sphere World demo scene

Additionally the following cleanup was performed:

  • Modify XRToolsPlayerBody to have common rotation code (extracted from turn and glide)

image
image

@BastiaanOlij
Copy link
Member

Absolutely love the idea but as I mentioned on Discord, not a fan of the approach. We're reinventing the wheel of the physics engine here and as a result we're only have parts of our own implementation playing by our own rules while other parts of the physics engine plays with it's rules.

In order to create the behavior we're after in Godots build in physics engine you use area nodes that override the gravity within that area from the default, see space_override.
To create spherical gravity you enabled gravity_point and set the center of gravity by setting gravity_vec

Note that with gravity_point set to false gravity_vec works the same as the implementation offered here.

We would still need to change our functions in similar ways but we're now getting our information from the same source the physics engine is getting it from resulting in objects that use the build in logic from behaving the same as our player. Ergo if you're at the bottom of your planet and you throw something, they don't fall off into space.

@Malcolmnixon Malcolmnixon force-pushed the origin-based-gravity branch 3 times, most recently from 49a49ea to 79b489d Compare December 24, 2022 04:26
@Malcolmnixon
Copy link
Collaborator Author

Updated the pull request to use physics gravity rather than orientation providers. The movement providers can now access both "up_player" and "up_gravity" information as appropriate for the motion. Movement providers can also perform a pre-processing step of changing the gravity - this is necessary for the wall-walking movement provider to have the player stick to the walls, while still supporting all other actions (running, jumping, etc).

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.

Very cool addition, this is pretty cool

…ector. Added demo scene with ground-following movement provider to test the new up-vector logic.

Added player orientation provider support to the XRToolsPlayerBody. Added ground and area orientation providers. Added path, point, and uniform orient areas to control the player orientation in different areas. Enhanced origin gravity demo to use orient areas to better handle player movement around the sphere and pill shapes.

Removed experimental world-grab provider not intended for this PR

Fixed climbing to work in the players orientation. Fixed flight to work in the players orientation. Fixed glide to work in the players orientation. Added sphere world demo.

Removed orientation providers - orientation now comes from gravity as detected by the player body. Modified gravity demos to use standard Area nodes with space_override settings. Added movement_wall_walk to walk on walls of the specified physics layer.

Further cleanup of orientation providers and unnecessary changes.

Modified XRToolsPlayerBody to split "up" into "up_player" and "up_gravity" as both are needed in different circumstances. Added physics_pre_movement() method to movement providers to let them perform initial service actions such as messing with gravity. Modified wall_walk movement to check for walking walls, and to modify the gravity to point to them.

Fixed gravity center for the sphere world demo.
@Malcolmnixon Malcolmnixon merged commit fe46c9c into GodotVR:master Dec 24, 2022
@Malcolmnixon Malcolmnixon deleted the origin-based-gravity branch December 24, 2022 13:11
@BastiaanOlij BastiaanOlij added the enhancement New feature or request label Jan 9, 2023
@BastiaanOlij BastiaanOlij added this to the 3.2.0 milestone Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants