Player Control Switch Discussion...

Post Reply
User avatar
TenPlus1
Member
Posts: 3728
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Player Control Switch Discussion...

by TenPlus1 » Post

Wouldn't it be great if a new flag was added to the player overrides that would allow mods to switch player control on/off, and when switched off mods could use the set_velocity() and set_acceleration() functions with the player model ?

e.g.

Code: Select all

player:set_physics_override({control=false}) -- turn off player control/movement
player:set_acceleration({x=0,y=20,z=0})
player:set_physics_override({control=true}) -- turn on player control
This would be a great addition to not only add player-knockback into the game, but many other features that modders could add into your worlds :) Let's discuss this below or here in forum:-

Link: https://github.com/minetest/minetest/issues/8567

User avatar
TenPlus1
Member
Posts: 3728
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: Player Control Switch Discussion...

by TenPlus1 » Post

Some ideas:

- Players would be able to build TNT cannons and launch themselves (or other players) across the map :)
- Removing player control for jailed players... naughty naughty!

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: Player Control Switch Discussion...

by Joseph16 » Post

I like the tnt idea. We really need good knockback in minetest.
Testin' mines since 1989

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: Player Control Switch Discussion...

by Joseph16 » Post

I like the tnt idea. We really need good knockback in minetest.
uhh forum? are you ok?
Testin' mines since 1989

User avatar
Joseph16
Member
Posts: 310
Joined: Tue Dec 06, 2016 05:35
In-game: smb3

Re: Player Control Switch Discussion...

by Joseph16 » Post

+9999999
Testin' mines since 1989

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: Player Control Switch Discussion...

by sorcerykid » Post

Knockback and similar physical effects should be managed client side, since the client is already responsible for velocity, acceleration, and collision detection of the player object.

User avatar
TenPlus1
Member
Posts: 3728
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: Player Control Switch Discussion...

by TenPlus1 » Post

That would be the ideal in this case sorcerykid, hopefully without the need for a csm mod :)

pgimeno
Member
Posts: 17
Joined: Fri May 03, 2019 12:10
GitHub: ghost
IRC: PGimeno
In-game: pgmine

Re: Player Control Switch Discussion...

by pgimeno » Post

My idea of player knockback is a function like

Code: Select all

player:apply_impulse(velocity_change)
which sends the change to the client, and upon reception, the client adds the given vector to the player's current internal velocity. No need to override controls or to apply acceleration; just let normal friction and controls do their job, like what happens when e.g. on ice.

pgimeno
Member
Posts: 17
Joined: Fri May 03, 2019 12:10
GitHub: ghost
IRC: PGimeno
In-game: pgmine

Re: Player Control Switch Discussion...

by pgimeno » Post

For a quick proof of concept of the above idea, try this patch:

Code: Select all

diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp
index dabeee6f..fd440e8b 100644
--- a/src/client/localplayer.cpp
+++ b/src/client/localplayer.cpp
@@ -198,6 +198,11 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
        bool noclip = m_client->checkLocalPrivilege("noclip") && player_settings.noclip;
        bool free_move = player_settings.free_move && fly_allowed;
 
+       static bool prevclip = false;
+       if (noclip != prevclip)
+               m_speed += v3f(100.f, 0.f, 0.f);
+       prevclip = noclip;
+
        if (noclip && free_move) {
                position += m_speed * dtime;
                setPosition(position);
then grant yourself the noclip privilege and point west. Every time you toggle noclip, your speed gets added 10 m/s to simulate a knockback. Try it without controls or while moving forward or backward.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests