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

Fix move_and_slide wall slide acceleration (3D) #90915

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

rburing
Copy link
Member

@rburing rburing commented Apr 19, 2024

When travel is high enough, keep the global position resulting from the move_and_collide call, and set the motion to the remainder from the move_and_collide call. This ensures travel is taken into account once, rather than twice.

This is also consistent with the other branch:

// If the movement is not canceled we only keep the remaining.
motion = result.remainder;

Thanks to @Calinou for extra testing.

When travel is high enough, keep the global position resulting from the
move_and_collide call, and set the motion to the remainder from the
move_and_collide call. This ensures travel is taken into account once,
rather than twice.
@rburing rburing requested a review from a team as a code owner April 19, 2024 18:21
@AThousandShips AThousandShips added this to the 4.3 milestone Apr 20, 2024
@rburing
Copy link
Member Author

rburing commented Apr 20, 2024

For ease of reviewing: the travel is taken into account in the call

bool collided = move_and_collide(parameters, result, false, !sliding_enabled);

which passes p_test_only = false into move_and_collide:

if (!p_test_only) {
Transform3D gt = p_parameters.from;
gt.origin += r_result.travel;
set_global_transform(gt);
}

Copy link
Contributor

@fabriceci fabriceci left a comment

Choose a reason for hiding this comment

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

Great job!

I had a bit of free time and I was looking to fix this problem, I found the PR while looking for the issues :)

To add a bit of context, this line belongs to a block of code that cancels a movement when you run against a surface considered to be a wall.

If the speed is too fast, the movement cannot be reversed as this would create a gap between the wall and the body.

(Prepare yourself for a very high quality graphic)
Screenshot 2024-04-24 at 22 22 58

It was a case I hadn't anticipated!

I tested the reproduction project of the bug as well as the scenario I illustrated to see if it still works properly, and everything is perfect!

@akien-mga akien-mga merged commit f819c77 into godotengine:master Apr 25, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@rburing rburing deleted the no_more_speedrun branch April 25, 2024 10:28
@akien-mga akien-mga added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Apr 25, 2024
@akien-mga
Copy link
Member

Cherry-picked for 4.2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment