Minetest_game: Player API: Animation-dependent player model collisionbox

Created on 30 Jun 2018  路  20Comments  路  Source: minetest/minetest_game

Issue type
  • Feature request
Minetest version

Any I think

Summary

When a player dies, he leaves a dead body, which AFAIK only disappears when this player hits the respawn button. And this dead body has bad collision box & prevents for instance firearms from shooting through. IMO, dead body should disappear after 5 secs or so, and not only when respawn button is pressed. I know that might pose a problem, as the player entity has to be somewhere even while he's dead, but why not temporarily remove model & collisionbox, make them invisible ?

I'm pretty sure I can't change that outta a mod...

Feature request Supported by core dev

Most helpful comment

I assume you mean 'bad collision box' as in an upright box for a player laying down. And i assume the selection box is the issue not the collision box.
I think the body should remain until 'respawn'. I disagree with removing the selectionbox even if it is the wrong shape, after all the body should be selectable as it is an obstacle.
Instead are we able to give a dead body the correct shape selectionbox (EDIT: and collisionbox)? That seems better, this may be doable in MTG.

All 20 comments

https://github.com/minetest/minetest/blob/f3b7be97feb5f1de8f31c1841cb7fdd3d89ac451/src/content_cao.cpp#L345-L346
Extend with || m_hp == 0 and
https://github.com/minetest/minetest/blob/f3b7be97feb5f1de8f31c1841cb7fdd3d89ac451/src/content_sao.cpp#L821
with || m_hp == 0

Easy PR. Makes the selection box not selectable for dead objects but keeps the model to indicate that the player died (nametag will also be there).

What does the Beginner Friendly label mean ?

It means that it's friendly to beginners.

In the game or in implementation ?

I assume you mean 'bad collision box' as in an upright box for a player laying down. And i assume the selection box is the issue not the collision box.
I think the body should remain until 'respawn'. I disagree with removing the selectionbox even if it is the wrong shape, after all the body should be selectable as it is an obstacle.
Instead are we able to give a dead body the correct shape selectionbox (EDIT: and collisionbox)? That seems better, this may be doable in MTG.

Your assumptions are right.

if we give the body the correct selectionbox, it should have a correct collisionbox, too. It's strange when selectionbox and collisionbox are different. Plus, you should give a dead body more gravity(=more acceleration downwards). I may open a new feature request/issue : I really want to be able to access player velocity/acceleration etc. from a mod, just like with entities...
Then, if you gave the dead body that acceleration, check whether its speed changes. That means it has reached a solid node. If yes, start a player:move_to, and make him sink slowly downwards. And if the player want's to respawn, replace it with an entity. This entity should have a lifetime of ~20 secs.
How about that ?

@appgurueu, see the LuaEntitySAO methods section of lua_api.txt. I've provided two of them here for convenience:

it should have a correct collisionbox, too

Agreed, sorry to imply otherwise.

Plus, you should give a dead body more gravity

No, obviously.

There is an issue open about strange behaviour of dead bodies.

And if the player want's to respawn, replace it with an entity. This entity should have a lifetime of ~20 secs.

This is unclear, replace the dead body with an entity after player respawn?

@paramat : Okay, but leave it with normal grav, at least. "replacing with entity" - Yeah so the dead body doesn't disappear before it's lifetime ended. Could be done from a Mod.
@ClobberXD : Afaik you are wrong, as player extends it, yes, but in MT 0.4.16.1 I can't access those methods...

The body disappears when the player respawns because that is when the body comes back to life, otherwise would be unjustified complexity. In MTG that is when bones are placed.

Dev discussion is about latest master, not 0.4.16.

:-1: for request but giving a dead body the correct boxes may be a good idea.

What about a tomb stone? I set the character to another texture on hp = 0:
test1
test2

What's left of this PR now? Hasn't this been decided to be resolved in MTG?

See https://github.com/minetest/minetest_game/pull/2184#issuecomment-424050175 onwards, needs consideration.

Right, thanks.

SmallJoker's idea is quite interesting. It's unfortunate you've decided to drop the PR. :)

I have been thinking about this recently.
The underlying problem here is that the differing animations of the player model all have the same collisionbox (and eye height).
This is a significant issue and can be solved with alteration to the player API, i think SmallJoker's suggestion in #2184 is going in the right direction. I might work on this.
So i am transferring this to MTG.

Obviously, some animations of a player model are likely to require a different collisionbox and eye_height, for example when sitting or laying down. But the Player API is designed to have a single collisionbox and eye_height for all animations.
What i am thinking of is using SmallJoker's approach explained in https://github.com/minetest/minetest_game/pull/2184#issuecomment-424050175 , with collisionbox and eye_height defined as tables with values for each animation name.

It needs to be backwards compatible with registered models that do not have tables for collisionbox and eye_height. So considering collisionbox as an example i suggest this as an initial idea:

  • In player_api.set_animation(), the collisionbox field is tested for being a table or not.
  • If a table, set player collisionbox to the collisionbox determined by the animation being set.
  • If not a table (backwards compatibility), set player collisionbox to the model's single specified collisionbox.

Can anyone see any problems with this approach?
I am not sure if stepheight needs to alter per animation, but it could do with some uses.
player_api.set_animation() can already alter animation speed.

Obviously, some animations of a player model are likely to require a different collisionbox and eye_height, for example when sitting or laying down. But the Player API is designed to have a single collisionbox and eye_height for all animations.
What i am thinking of is using SmallJoker's approach explained in #2184 (comment) , with collisionbox and eye_height defined as tables with values for each animation name.

It needs to be backwards compatible with registered models that do not have tables for collisionbox and eye_height. So considering collisionbox as an example i suggest this as an initial idea:

In player_api.set_animation(), the collisionbox field is tested for being a table or not.
If a table, set player collisionbox to the collisionbox determined by the animation being set.
If not a table (backwards compatibility or no need for differing collisionboxes), do nothing and so continue to use the model's single specified collisionbox.

Can anyone see any problems with this approach?
I am not sure if stepheight needs to alter per animation, but it could do with some uses.
player_api.set_animation() can already alter animation speed.

That is the straightforward approach (except I would just check for falsy instead of checking for type)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paramat picture paramat  路  3Comments

TekhnaeRaav picture TekhnaeRaav  路  5Comments

Wuzzy2 picture Wuzzy2  路  5Comments

FeXoR-o-Illuria picture FeXoR-o-Illuria  路  4Comments

paramat picture paramat  路  3Comments