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 moving platform support to the player body #150

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

Malcolmnixon
Copy link
Collaborator

This implements feature request #149 by adding moving-platform support to the player body.

The approach is as follows:

  1. The _update_ground_information function calculates the ground-velocity (how fast the ground is moving) by analyzing how the contact-point under the players feet moves between frames - specifically how the point is transformed locally by the ground spatial node.
  2. The _apply_velocity_and_control function works in a ground-relative frame of reference by subtracting the ground-velocity at the start of the function, then adding it back in at the end.

There is one "hack" caused by the fact that the KinematicBody move_and_slide is an "instantaneous" function in that when it performs the move-and-slide, the universe is frozen. As such if the ground is moving down and the player is standing on it moving down at the same speed, the move-and-slide sees the ground as stationary at that instant and instead outputs a player vertical velocity of 0. The code detects a vertical velocity of 0 and instead treats it as the player moving at exactly the ground vertical velocity.

Even with this hack there is still some stuttering if the platform moves vertically. Further research may be warranted to try and stick the players feet to the ground, although crude attempts at doing this broke jumping.

@BastiaanOlij BastiaanOlij added the enhancement New feature or request label Jun 20, 2022
@BastiaanOlij BastiaanOlij added this to the 2.5.0 milestone Jun 20, 2022
Added moving platform support to the player body.
@Malcolmnixon
Copy link
Collaborator Author

Rebased with master to remove merge-conflict with VERSION.md

@BastiaanOlij BastiaanOlij merged commit 66d41b1 into GodotVR:master Jun 22, 2022
@Malcolmnixon Malcolmnixon deleted the moving-platform branch June 22, 2022 15:41
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