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

Refactor player height adjustment #475

Merged
merged 1 commit into from
Jul 29, 2023

Conversation

BastiaanOlij
Copy link
Member

This PR redoes the player height implementation.

Our default setting in project settings remains however our user settings now store a user overridden version of this.

As our loading screen has the "trigger to continue" logic we can assume the player is standing (or sitting) in "rest" and we calculate the offset required to make the virtual player the height stored in our settings.

This means XR tools can now be played while seated but controlling the character as if standing up.

Note that this is different from @pietru2004 PRs where we actually want the character to be seated (in a vehicle or otherwise) if I understand correctly. This is something we do want to support properly but I haven't had time to look into this properly.

@BastiaanOlij BastiaanOlij added the enhancement New feature or request label Jul 2, 2023
@BastiaanOlij BastiaanOlij added this to the 4.2.0 milestone Jul 2, 2023
@BastiaanOlij BastiaanOlij self-assigned this Jul 2, 2023
@pietru2004
Copy link
Contributor

pietru2004 commented Jul 2, 2023

My implementation of seat(newest one) disables playerbody and every frame sets transform origin to seat point+ adds rotation, all on xr origin. #462

@pietru2004
Copy link
Contributor

Also what effect would it have on #463 ?

@DigitalN8m4r3
Copy link
Contributor

hmm, gotta check this out then
it sounds like what am after, a way to force seated even if the player is actualy standing while preventing from changing height if the player actualy sits down/stnads up while using this. so correct me if am getting this the wrong way

@BastiaanOlij
Copy link
Member Author

BastiaanOlij commented Jul 7, 2023

@pietru2004 sorry I still need to look into your seated solution. It's indeed a bit of a conundrum, player body doesn't work for the situation where the game character is sitting so disabling it is the correct way forward, or possibly this should be a mode.
This PR thus has no impact on it because this PR is to deal with the end user sitting down or being of a different height while we fix the game characters height when standing.

@DigitalN8m4r3 this PR is the opposite, this is the scenario where your game character is standing up regardless of the end user (player) being seated or standing.

When you look at the scenario where the game character is seated, the game dynamics change drastically from what playerbody is designed for. Controller inputs now no longer effect the game character, say your game character is seated in a car, controller inputs will effect the car, it's the car that now moves, and the game character as a child node moves with the car.

The problem is anchoring your game character so they are seated in the correct position at the start.

For a game that only allows a seated position this is easy, you place the XROrigin where you want the players head to be and you wait until tracking information is stable and call XRServer.center_on_hmd(XRServer.RESET_BUT_KEEP_TILT ,false). Then you add a button hold feature or something to be able to reset that view by calling this again in case your player wasn't ready.

For a game where you want to be able to switch between a seated and standing position, say you want to make a VR version of GTA, you'll need to implement your own version of what center_on_hmd does behind the scenes, When standing playerbody is active and you control the character as we're used to, when the game character enters a car you disable playerbody, child XROrigin to the seat, and change its transform so the head ends up in the correct starting position.

The mistake I see many people make is to try and keep the head in place once the game character is seated and basically turn the game into a 3DOF game. You really really don't want this. When I'm in a car, I want to be able to move my head and look around, this also means moving your head positionally. If you disable this, not only do you induce motion sickness, you also hinder the player from making use of their natural ability to change the angle at which they are looking at something.

This however opens the door to the player moving beyond the space that they can naturally occupy. While hilarious the player can physically stand up and walk away, moving the players head outside of the vehicle.

The best way to handle this situation IMHO is by checking if the head moves out of the acceptable space and fade the screen to black (maybe with a message to press the reset button).
The approach I took in my vehicle tutorial was to simply calculate the distance between the ideal head position and the actual head position and fade the screen to black if this goes beyond an acceptable distance. When faded to black we still show a message to hold the button to recenter the screen.
This could be improved upon by using an Area3D node and a collision shape that denotes where the players head can be, and simply checking if the head is inside of the area.

@pietru2004
Copy link
Contributor

What about crouching in real life, mayby game does not use crouch function...

Copy link
Collaborator

@Malcolmnixon Malcolmnixon left a comment

Choose a reason for hiding this comment

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

This looks good - just need to resolve the merge conflicts.

@Malcolmnixon Malcolmnixon merged commit d7bb0b8 into GodotVR:master Jul 29, 2023
2 checks passed
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.

None yet

4 participants