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
A way to detect when a player jumps #9631
Comments
Actually, yes, there are no any API ways to check what nodes are beneath, except a workaround (calculate a position of the player bottom and retrieving the node by minetest.get_node at each step). I think it would be nice to get info about colliding result with other ones along to each global axle. Maybe is it a worth to add a callback like e.g. 'after_collide' for entity and node which a collision result table is passed to? |
Part of the reason this will be rather difficult to implement iirc, is because player physics are handled client-side. So that would require the server duplicate the calculations for player motion just to provide an API for scripts to check whether the player is in air, which is extremely infrequent. Now in fairness, I could be mistaken. I know there is cheat-detection code which likely performs these calculations anyway. So hopefully a core-dev can better clarify the technicalities. |
|
You need to code this to only check every few globalsteps, not every globalstep. |
Duplicate of #3918 EDIT: Not directly duplicate: This issue is not about a callback, and limited to Y+ collisions. Please note that even the client doesn't know whether it's standing on ground. For example: #1460 and the obscure #6959. |
Yes, because I stated before
I don't want to disrespect anyone's job because I honestly think what you're all doing is amazing and also because being a developer is not my job nor I studied for it, but info are scattered in at least three different sites and I often find myself going full trial and error to understand how something exactly works, it's... frustrating. So in short yes, I don't know how to reproduce it on Lua and I think it'd help a lot of people having about my same level of knowledge |
This was my take in Lua by the way:
There are still two consistent issues with the code:
That is, of course, if my method isn't plain wrong |
Sparing work to core devs, according to labels |
Problem
There doesn't seem to be any detection for when the player jumps. I tried checking the block beneath if it's equal to air on
minetest.register_globalstep
, but it gets called several times if I don't put some sort of boolean, adding unnecessary weight to the code. And, even if there is an easier way to do it, it doesn't seem intuitive for me at all (I checked both in the dev wiki and in the txt file)Solutions
Player:is_on_air()
(or is on ground, floor, orminetest.is_player_on_air(player)
etc., whatever) like Godot does withis_on_floor()
. Maybe checking if the collision box is actually colliding with something (idk how it works the C++ builtin part, sorry)EDIT by paramat: See lua code posted in #9631 (comment)
The issue author is actually trying to detect when a player jumps, which is very different to detecting "air" below a player.
Additional info
It looks like back in 2017 something asked about something pretty similar already without any answer, idk if it can help https://forum.minetest.net/viewtopic.php?f=47&t=17646
The text was updated successfully, but these errors were encountered: