2015-01-24 22:05:38 +03:00
|
|
|
---
|
|
|
|
title: Player Physics
|
|
|
|
layout: default
|
2018-07-15 21:36:35 +03:00
|
|
|
root: ../..
|
2018-07-15 17:28:10 +03:00
|
|
|
idx: 4.4
|
2018-07-15 21:13:16 +03:00
|
|
|
redirect_from: /en/chapters/player_physics.html
|
2015-01-24 22:05:38 +03:00
|
|
|
---
|
|
|
|
|
2015-02-22 13:28:37 +03:00
|
|
|
## Introduction
|
2015-01-24 22:05:38 +03:00
|
|
|
|
|
|
|
Player physics can be modified using physics overrides. Physics overrides can set the
|
|
|
|
walking speed, jump speed and gravity constants. Physics overrides are set on a player
|
2017-09-03 02:49:00 +03:00
|
|
|
by player basis, and are multipliers. For example, a value of 2 for gravity would make
|
|
|
|
gravity twice as strong.
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
* [Basic Example](#basic_example)
|
|
|
|
* [Available Overrides](#available_overrides)
|
|
|
|
* [Mod Incompatibility ](#mod_incompatibility)
|
|
|
|
* [Your Turn](#your_turn)
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
## Basic Example
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
Here is an example of how to add an antigravity command, which
|
2015-01-24 22:05:38 +03:00
|
|
|
puts the caller in low G:
|
|
|
|
|
2018-09-19 14:04:51 +03:00
|
|
|
```lua
|
2016-07-01 20:47:31 +03:00
|
|
|
minetest.register_chatcommand("antigravity", {
|
2017-08-26 21:01:51 +03:00
|
|
|
func = function(name, param)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
player:set_physics_override({
|
|
|
|
gravity = 0.1 -- set gravity to 10% of its original value
|
|
|
|
-- (0.1 * 9.81)
|
|
|
|
})
|
|
|
|
end
|
2015-01-24 22:05:38 +03:00
|
|
|
})
|
2018-09-19 14:04:51 +03:00
|
|
|
```
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
## Available Overrides
|
2015-01-24 22:05:38 +03:00
|
|
|
|
|
|
|
player:set_physics_override() is given a table of overrides.\\
|
2018-07-15 21:36:35 +03:00
|
|
|
According to [lua_api.txt]({{ page.root }}/lua_api.html#player-only-no-op-for-other-objects),
|
2015-01-24 22:05:38 +03:00
|
|
|
these can be:
|
|
|
|
|
|
|
|
* speed: multiplier to default walking speed value (default: 1)
|
|
|
|
* jump: multiplier to default jump value (default: 1)
|
|
|
|
* gravity: multiplier to default gravity value (default: 1)
|
|
|
|
* sneak: whether player can sneak (default: true)
|
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
### Old Movement Behaviour
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
Player movement prior to the 0.4.16 release included the sneak glitch, which
|
|
|
|
allows various movement glitches, including the ability
|
|
|
|
to climb an 'elevator' made from a certain placement of nodes by sneaking
|
|
|
|
(pressing shift) and pressing space to ascend. Though the behaviour was
|
|
|
|
unintended, it has been preserved in overrides due to its use on many servers.
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
Two overrides are needed to fully restore old movement behaviour:
|
|
|
|
|
|
|
|
* new_move: whether the player uses new movement (default: true)
|
2018-07-16 01:04:55 +03:00
|
|
|
* sneak_glitch: whether the player can use "sneak elevators" (default: false)
|
2017-09-03 02:49:00 +03:00
|
|
|
|
2018-07-15 17:28:10 +03:00
|
|
|
## Mod Incompatibility
|
2017-09-03 02:49:00 +03:00
|
|
|
|
|
|
|
Please be warned that mods which override the same physics value of a player tend
|
2015-01-24 22:05:38 +03:00
|
|
|
to be incompatible with each other. When setting an override, it overwrites
|
2017-09-03 02:49:00 +03:00
|
|
|
any overrides that have been set before. This means that if multiple overrides set a
|
|
|
|
player's speed, only the last one to run will be in effect.
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2015-02-22 13:28:37 +03:00
|
|
|
## Your Turn
|
2015-01-24 22:05:38 +03:00
|
|
|
|
2017-09-03 02:49:00 +03:00
|
|
|
* **Sonic**: Set the speed multiplier to a high value (at least 6) when a player joins the game.
|
|
|
|
* **Super bounce**: Increase the jump value so that the player can jump 20 meters (1 meter is 1 node).
|
|
|
|
* **Space**: Make gravity decrease as the player gets higher.
|