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

Physics override not working properly when speed is set to 0 while moving #10037

Open
Zughy opened this issue Jun 14, 2020 · 11 comments
Open

Physics override not working properly when speed is set to 0 while moving #10037

Zughy opened this issue Jun 14, 2020 · 11 comments
Labels
Bug Issues that were confirmed to be a bug @ Client / Audiovisuals High priority

Comments

@Zughy
Copy link
Contributor

Zughy commented Jun 14, 2020

Minetest version
5.2.0
Summary

Trying to set

player:set_physics_override({
              speed = 0,
              })

doesn't work properly while a movement key is held down (players slide in the last direction they were moving to). I've tried with set_velocity and set_acceleration equal to {x=0,y=0,z=0} but again no luck

Steps to reproduce

Overrides physics to 0 while moving

@Zughy Zughy added the Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible label Jun 14, 2020
@ClobberXD
Copy link
Contributor

Is this just how it appears to the client, or does the server actually register the player as moving? I'm betting on the former, as you mention set_velocity doesn't have an effect.

@sfan5
Copy link
Collaborator

sfan5 commented Jun 15, 2020

The reason for this is that setting speed to zero not only prevents acceleration but also deceleration (parameters here).

I've tried with set_velocity and set_acceleration equal to {x=0,y=0,z=0} but again no luck

Note the these methods do nothing for players.

@sfan5 sfan5 added @ Client / Audiovisuals Bug Issues that were confirmed to be a bug and removed Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible labels Jun 15, 2020
@appgurueu
Copy link
Contributor

IMO not a bug as velocity should be kept. You can use player:add_velocity(vector.multiply(player:get_player_velocity(), -1)) BTW.

@ghost
Copy link

ghost commented Jun 18, 2020 via email

@Zughy
Copy link
Contributor Author

Zughy commented Jun 18, 2020

IMO not a bug as velocity should be kept. You can use player:add_velocity(vector.multiply(player:get_player_velocity(), -1)) BTW.

I don't agree as it's pretty unintuitive. I'd expect to have the player unable to move if I set speed = 0

@hecktest
Copy link
Contributor

hecktest commented Jul 9, 2020

set/add velocity does not work for players.
Using the movement speed as a friction coefficient is a bug.

@Zughy Zughy changed the title Physics override not working properly when set to 0 while moving Physics override not working properly when speed is set to 0 while moving Oct 23, 2020
@appgurueu
Copy link
Contributor

set/add velocity does not work for players.

It does (used to be called add_player_velocity though), only possible problem might be desync. As a workaround, you should probably attach the player to an invisible entity.

Using the movement speed as a friction coefficient is a bug.

true

@hecktest
Copy link
Contributor

Oh, sorry, I was looking at outdated (0.4) documentation. Back in the day there was truly no way to manipulate player velocity, which was pretty frustrating.

@appgurueu
Copy link
Contributor

Oh, sorry, I was looking at outdated (0.4) documentation. Back in the day there was truly no way to manipulate player velocity, which was pretty frustrating.

Back in the day modders would temporarily attach players to entities to move them :'-)

matteobin added a commit to matteobin/minetest that referenced this issue Sep 12, 2023
Fixes luanti-org#10037. Why the overridden speed is used as a coefficient to
calculate accelaration?
matteobin added a commit to matteobin/minetest that referenced this issue Sep 12, 2023
Fixes luanti-org#10037. Why the overridden speed is used as a coefficient to
calculate acceleration?
@grorp
Copy link
Member

grorp commented Nov 8, 2023

For backwards compatibility, we can't change the behavior of the speed physics override so that it doesn't affect acceleration (and deceleration).

Fortunately, with #11465 already merged and #13815 hopefully coming soon, you will be able to control all speed values separetely (using speed_walk, speed_climb, speed_crouch and speed_fast). These new overrides don't affect acceleration, so this issue can be solved by replacing

player:set_physics_override({
    speed = 0,
})

with

player:set_physics_override({
    speed = 1,
    speed_walk = 0,
    speed_climb = 0,
    speed_crouch = 0,
    speed_fast = 0,
    -- The following is optional and causes the player to stop immediately
    -- instead of coming to a halt more slowly.
    acceleration_default = math.huge,
    acceleration_air = math.huge,
    acceleration_fast = math.huge,
})

However, #13796 could still be an option to make the behavior of speed more reasonable.

@Zughy
Copy link
Contributor Author

Zughy commented Nov 8, 2023

@grorp yes, #13796 is way easier. What you've suggested sounds like a messy hack (no offence)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Client / Audiovisuals High priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants