wareya / GodotStairTester

Test project for stair-stepping in Godot 4
Creative Commons Zero v1.0 Universal
17 stars 2 forks source link

Jump doesn't work if actively pressing forward into a wall #7

Open robotjunkyard opened 8 months ago

robotjunkyard commented 8 months ago

Jump doesn't seem to work on a frame in which the player is actively pressing the character into a wall.

Physics code is not something I ever understood very well (hence only doing RPGs and puzzle games until recently), but I did try to narrow down some things by tinkering with numbers, which I hope helps:

In the line of code where it goes:

velocity.y = jumpvel

If jumpvel is multiplied by some number all the way up to 7.0, it still doesn't work. However, multiplying it by 7.1, it is able to "escape" whatever it is about the wall that is holding the character down. (of course, the character jumps way, way, way too high, so this isn't a solution)

That aside, I also tried making it so pressing jump toggles a "wish_to_jump" boolean in the player, and then making the y velocity change get changed on a "if wish_to_jump and on_the_floor():" block... and then tried plopping that block around other parts of the code wherever the player's physics properties get changed, but did not achieve any different results.

wareya commented 8 months ago

Works for me. Are you using your own acceleration code? Jolt physics? Are you setting floor_snap_length? etc.

robotjunkyard commented 8 months ago

I wasn't using custom character controller code beyond this project's player controller, and floor_snap_length is 0.1, which I think is the default since it doesn't show that circular curly-arrow by it.

But indeed, changing the physics engine from Jolt back to Godot's native engine seems to have alleviated the issue!

wareya commented 8 months ago

Thanks for troubleshooting. I'll take a look at using this with Jolt at some point in the next couple months; I'm a big busy IRL atm.

robotjunkyard commented 8 months ago

If I stumble upon a solution (I'm still tinkering with this code) I'll be sure to send a pull request.

robotjunkyard commented 8 months ago

One more follow-up: sorry, I was daydreaming earlier and was incorrect about my original answer about not using custom acceleration, and should probably mention for completeness sake: in my edit of the player movement script, the unit_conversion const was changed to 32.0 (scaled for almost-Quake-like speed in my game where 2 meters is 64 texels, as a result of setting inverse_scale_factor in Qodot maps also to 32.0).

I could not replicate the problem in this vanilla GodotStairsTester project where unit_conversion is 64.0, even with Jolt being used it jumps against walls just fine, but when that value is set to 32.0 it happens -- I presume because the character runs twice as fast, perhaps Jolt doesn't like that for some reason.

Come to think of it, this might be a bug appropriate for the Godot-Jolt team and not necessarily this project... really hard to tell, but I'll experiment some more.