[testserver] y_bows: it's too easy to hit yourself #5974

Closed
opened 2024-01-14 01:21:22 +00:00 by whosit · 31 comments
Member

It's very easy to hit yourself while moving forward (depends on the bow charge, but still too easy).

I also hit myself while sitting on a chair and looking around 45 degrees down.

Solving this by moving the spawning point of the arrow forward may allow shooting through thin objects...
Maybe better solution would be to ignore collisions with the "shooter" for some steps after arrow is shot?

It's very easy to hit yourself while moving forward (depends on the bow charge, but still too easy). I also hit myself while sitting on a chair and looking around 45 degrees down. Solving this by moving the spawning point of the arrow forward may allow shooting through thin objects... Maybe better solution would be to ignore collisions with the "shooter" for some steps after arrow is shot?
whosit added the
1. kind/bug
label 2024-01-14 01:21:31 +00:00
flux was assigned by whosit 2024-01-14 01:21:35 +00:00
Member

there's no way to ignore some collisions but not all of them. but the distance where the arrow spawns w/ respect to the player could be adjusted based on player velocity and server lag. but that's not necessarily going to solve everything.

there's no way to ignore some collisions but not all of them. but the distance where the arrow spawns w/ respect to the player could be adjusted based on player velocity and server lag. but that's not necessarily going to solve everything.
flux added the
3. source/mod upstream
4. step/at work
labels 2024-01-14 19:23:43 +00:00
flux added this to the flux's TODO list project 2024-01-14 19:23:49 +00:00
Member

actually i could make it so that collide_with_objects is disabled on the first arrow step too, that'd help.

actually i could make it so that `collide_with_objects` is disabled on the first arrow step too, that'd help.
Author
Member

If projectile stores who launched it, then it should be possible to check in on_step() if the collided object in moveresult is the shooter? What happens if you just set_current_velocity(old_velocity)? (assuming engine updates it for you before calling on_step())?

I should experiment with it myself...

If projectile stores who launched it, then it should be possible to check in `on_step()` if the collided object in `moveresult` is the shooter? What happens if you just set_current_velocity(old_velocity)? (assuming engine updates it for you before calling `on_step()`)? I should experiment with it myself...
Member

If projectile stores who launched it, then it should be possible to check in on_step() if the collided object in moveresult is the shooter? What happens if you just set_current_velocity(old_velocity)? (assuming engine updates it for you before calling on_step())?

I should experiment with it myself...

the thing is, the collision will still affect the projectile's velocity. i suppose we could use that to keep the arrow from punching the player and making a "ding" sound, but the arrow still wouldn't go very far. i made it so that arrows can't collide with objects on the first step, let's see how well that works before doing anything weirder. f67a2794df

> If projectile stores who launched it, then it should be possible to check in `on_step()` if the collided object in `moveresult` is the shooter? What happens if you just set_current_velocity(old_velocity)? (assuming engine updates it for you before calling `on_step()`)? > > I should experiment with it myself... the thing is, the collision will still affect the projectile's velocity. i suppose we could use that to keep the arrow from punching the player and making a "ding" sound, but the arrow still wouldn't go very far. i made it so that arrows can't collide with objects on the first step, let's see how well that works before doing anything weirder. https://github.com/fluxionary/minetest-ballistics/commit/f67a2794dff4c40be0065050c9e9edfb3e600a86
Member

i made it so that arrows can't collide with objects on the first step

ugh this makes it so that "i can't hit this mob that's right in front of me if there's lag"

> i made it so that arrows can't collide with objects on the first step ugh this makes it so that "i can't hit this mob that's right in front of me if there's lag"
Author
Member

I think this will be just a limitation of using moveresult for collision.
It's called "tunneling" and the only way to avoid this problem is using ray tracing (or something even fancier) between server steps...

Basically what x_bows was doing. And also, it will be easy to check for collisions with the shooter.

I think this will be just a limitation of using `moveresult` for collision. It's called "tunneling" and the only way to avoid this problem is using ray tracing (or something even fancier) between server steps... Basically what x_bows was doing. And also, it will be easy to check for collisions with the shooter.
Member

I think this will be just a limitation of using moveresult for collision.
It's called "tunneling" and the only way to avoid this problem is using ray tracing (or something even fancier) between server steps...

Basically what x_bows was doing. And also, it will be easy to check for collisions with the shooter.

yeah, the solution i was working on was using raytracing for the first step, then i encountered problems because i discovered the "estimated collision position" isn't working nearly as well as i thought it was. i'm wondering if i should give up on physical projectiles and move to pure raytracing. the problem is i'd need a way to interpolate the parabolic path, which i wanted to avoid.

> I think this will be just a limitation of using `moveresult` for collision. > It's called "tunneling" and the only way to avoid this problem is using ray tracing (or something even fancier) between server steps... > > Basically what x_bows was doing. And also, it will be easy to check for collisions with the shooter. yeah, the solution i was working on was using raytracing for the first step, then i encountered problems because i discovered the "estimated collision position" isn't working nearly as well as i thought it was. i'm wondering if i should give up on physical projectiles and move to pure raytracing. the problem is i'd need a way to interpolate the parabolic path, which i wanted to avoid.
Author
Member

What do you think the problems are with using Verlet integration for physics and assuming that arrows travel in straight lines between timesteps?

What do you think the problems are with using [Verlet integration](https://en.wikipedia.org/wiki/Verlet_integration) for physics and assuming that arrows travel in straight lines between timesteps?
Member

What do you think the problems are with using Verlet integration for physics and assuming that arrows travel in straight lines between timesteps?

i've never heard of verlet integration before, i figured someone must have solved the problem but i hadn't found the solution myself. i'll dig into that, maybe tomorrow. part of me wants to take a break from coding projectile code to deep-think about it.

> What do you think the problems are with using [Verlet integration](https://en.wikipedia.org/wiki/Verlet_integration) for physics and assuming that arrows travel in straight lines between timesteps? i've never heard of verlet integration before, i figured *someone* must have solved the problem but i hadn't found the solution myself. i'll dig into that, maybe tomorrow. part of me wants to take a break from coding projectile code to deep-think about it.
Member

Discretisation error

yeah this is exactly what i didn't want to derive myself. it still looks terrible, but not beyond me.

> Discretisation error yeah this is exactly what i didn't want to derive myself. it still looks terrible, but not beyond me.
Author
Member

https://en.wikipedia.org/wiki/Verlet_integration#Algorithmic_representation
Exact solution may not be necessary. Simple code similar to this example could be good enough for a game XD

https://en.wikipedia.org/wiki/Verlet_integration#Algorithmic_representation Exact solution may not be necessary. Simple code similar to this example could be good enough for a game XD
Member

https://en.wikipedia.org/wiki/Verlet_integration#Algorithmic_representation

apparently the verlet method isn't appropriate when drag is involved - the drag calculations on the algorithm in wikipedia are deeply wrong. the internet suggests instead https://en.wikipedia.org/wiki/Midpoint_method

> https://en.wikipedia.org/wiki/Verlet_integration#Algorithmic_representation apparently the verlet method isn't appropriate when drag is involved - the drag calculations on the algorithm in wikipedia are deeply wrong. the internet suggests instead https://en.wikipedia.org/wiki/Midpoint_method
Member

i spent today understanding the midpoint method well enough to code something, but it remains to be tested.

i spent today understanding the midpoint method well enough to code something, but it remains to be tested.
Author
Member

Would be interesting to see the difference between the two methods.
Midpoint will be more computationally expensive, if I understand it correctly? (if our step size = dtime...)
Of course, trajectories will differ because of error, but will it matter for the gameplay?
I would lean towards more simple method that just feels "good enough".

But this is just my guessing, better see the actual comparison.

Would be interesting to see the difference between the two methods. Midpoint will be more computationally expensive, if I understand it correctly? (if our step size = dtime...) Of course, trajectories will differ because of error, but will it matter for the gameplay? I would lean towards more simple method that just feels "good enough". But this is just my guessing, better see the actual comparison.

If one lags us significantly less than the other, while the other doesn't have a really big correctness (or other) advantage, then I'd prefer the less laggy one.

Ofc I'd also be interested in comparisons and benchmarks :D

Btw, the method currently on the testserver already looks quite nice, what's wrong with it?

If one lags us significantly less than the other, while the other doesn't have a really big correctness (or other) advantage, then I'd prefer the less laggy one. Ofc I'd also be interested in comparisons and benchmarks :D Btw, the method currently on the testserver already looks quite nice, what's wrong with it?
Author
Member

If one lags us significantly less than the other, while the other doesn't have a really big correctness (or other) advantage, then I'd prefer the less laggy one.

Ofc I'd also be interested in comparisons and benchmarks :D

What if additional lag it's not significant for a limited amount of projectiles? ;p

Btw, the method currently on the testserver already looks quite nice, what's wrong with it?

Besides hitting yourself - we need to have some irregular and large timesteps to see what may be wrong.
How can we get dtimes of 1.5 on the test?
/create_lag 1000000 3 (command from mesecons_debug) for 1/3 chance of 1 second lag.

> If one lags us significantly less than the other, while the other doesn't have a really big correctness (or other) advantage, then I'd prefer the less laggy one. > > Ofc I'd also be interested in comparisons and benchmarks :D What if additional lag it's not significant for a limited amount of projectiles? ;p > Btw, the method currently on the testserver already looks quite nice, what's wrong with it? Besides hitting yourself - we need to have some irregular and large timesteps to see what may be wrong. ~~How can we get dtimes of 1.5 on the test?~~ `/create_lag 1000000 3` (command from `mesecons_debug`) for 1/3 chance of 1 second lag.
Author
Member

With /create_lag 1000000 1.3 (75% chance of second lag) many arrows seem to disappear similar to how spears do....

With a constant lag I cannot hit a dolphin from up close... For a moment moveresult looked not too bad while shooting at walls... but hitting entities during lag just does not work it seems.

With `/create_lag 1000000 1.3` (75% chance of second lag) many arrows seem to disappear similar to how spears do.... With a constant lag I cannot hit a dolphin from up close... For a moment `moveresult` looked not too bad while shooting at walls... but hitting entities during lag just does not work it seems.
Member

many arrows seem to disappear similar to how spears do

so far as i understand this currently, this is because the physical arrow collides with one thing, continues to move, collides with another, and then i try to guess where the original collision was. i need to try to retrace the path better if there's multiple collisions. i need to play around with that more, but it seems to be non-trivial. i really wish that the engine just reported the position of the object when it collided. this is one of the main things that make me think that i'll have to just give up on using physical entities and instead do a bunch of interpolated raycasting. ugh.

> many arrows seem to disappear similar to how spears do so far as i understand this currently, this is because the physical arrow collides with one thing, continues to move, collides with another, and then i try to guess where the original collision was. i need to try to retrace the path better if there's multiple collisions. i need to play around with that more, but it seems to be non-trivial. i really wish that the engine just reported the position of the object when it collided. this is one of the main things that make me think that i'll have to just give up on using physical entities and instead do a bunch of interpolated raycasting. ugh.
Member

Midpoint will be more computationally expensive, if I understand it correctly?

it's not meaningfully more expensive, if at all - the algorithm is very similar.

With /create_lag 1000000 1.3 (75% chance of second lag) many arrows seem to disappear similar to how spears do

this is because my math to compute the estimated "collision point" doesn't work great with lots of lag, hence the need for something better.

the midpoint method estimation seems to work incredibly in practice. however, (1) projectiles under-shoot when there's significant lag (300ms server steps). that's not a bug with the midpoint method, though. (2) it goes nuts when the projectile is shot from or enters viscous nodes (e.g. water). i might leave fixing those things to a later release.

the code is currently in a bit of a messy state with tons of debug statements. i'll try to clean that up tomorrow, i've got to IRL now.

> Midpoint will be more computationally expensive, if I understand it correctly? it's not meaningfully more expensive, if at all - the algorithm is very similar. > With /create_lag 1000000 1.3 (75% chance of second lag) many arrows seem to disappear similar to how spears do this is because my math to compute the estimated "collision point" doesn't work great with lots of lag, hence the need for something better. the midpoint method estimation seems to work incredibly in practice. however, (1) projectiles under-shoot when there's significant lag (300ms server steps). that's not a bug with the midpoint method, though. (2) it goes nuts when the projectile is shot from or enters viscous nodes (e.g. water). i might leave fixing those things to a later release. the code is currently in a bit of a messy state with tons of debug statements. i'll try to clean that up tomorrow, i've got to IRL now.
Member

i've got a limiter in the arrow drag logic that keeps drag from doing something stupid like making the projectile suddenly turn around. there's no direct way to translate that to the midpoint method's approximate integration, but perhaps decreasing the time-step by 10x or 100x when in a fluid node would solve the problem. but that could have a performance impact? will have to test it.

i've got a limiter in the arrow drag logic that keeps drag from doing something stupid like making the projectile suddenly turn around. there's no direct way to translate that to the midpoint method's approximate integration, but perhaps decreasing the time-step by 10x or 100x when in a fluid node would solve the problem. but that could have a performance impact? will have to test it.
Member

i've got a limiter in the arrow drag logic that keeps drag from doing something stupid like making the projectile suddenly turn around.

actually, that might be the source of arrows not traveling as far as they should when the server is lagging? the code enforces that drag shouldn't cause a reverse in direction, but i think the solution is more complicated than that. it shouldn't be able to decrease the speed by more than some unknown but positive value.

> i've got a limiter in the arrow drag logic that keeps drag from doing something stupid like making the projectile suddenly turn around. actually, that might be the source of arrows not traveling as far as they should when the server is lagging? the code enforces that drag shouldn't cause a reverse in direction, but i think the solution is more complicated than that. it shouldn't be able to decrease the speed by more than some unknown but positive value.
Author
Member

(1) projectiles under-shoot when there's significant lag (300ms server steps). that's not a bug with the midpoint method, though.

Are you using substeps for integration, or just taking dtime? Maybe long step could be split into multiple shorter ones. Kinda like "catch-up"? Don't think there's a need for step/10, just a constant minimum "server step" maybe?

Also, looking at parabola and comparing tangents that Euler and midpont methods use - seems like euler will always overshoot and midpoint will always undershoot?

> (1) projectiles under-shoot when there's significant lag (300ms server steps). that's not a bug with the midpoint method, though. Are you using substeps for integration, or just taking dtime? Maybe long step could be split into multiple shorter ones. Kinda like "catch-up"? Don't think there's a need for step/10, just a constant minimum "server step" maybe? Also, looking at parabola and comparing tangents that Euler and midpont methods use - seems like euler will always overshoot and midpoint will always undershoot?
Member

Are you using substeps for integration, or just taking dtime?

i'm using constant-sized substeps currently (0.09s, but i may need to decrease it to maybe 0.01 to deal with water). but the actual objects on the server are using dtime (see https://github.com/minetest/minetest/issues/12340 and the associated PR for discussion).

looking at parabola and comparing tangents that Euler and midpont methods use - seems like euler will always overshoot and midpoint will always undershoot?

https://indico.cern.ch/event/831093/attachments/1896309/3218515/ub_py410_odes.pdf

according to this (and some other things i found), euler tends to overshoot, and midpoint tends to be "more or less correct". if anything, midpoint is over-shooting in practice.

(red dots are the expected path according to midpoint method)
image

> Are you using substeps for integration, or just taking dtime? i'm using constant-sized substeps currently (0.09s, but i may need to decrease it to maybe 0.01 to deal with water). but the actual objects on the server are using dtime (see https://github.com/minetest/minetest/issues/12340 and the associated PR for discussion). > looking at parabola and comparing tangents that Euler and midpont methods use - seems like euler will always overshoot and midpoint will always undershoot? https://indico.cern.ch/event/831093/attachments/1896309/3218515/ub_py410_odes.pdf according to this (and some other things i found), euler tends to overshoot, and midpoint tends to be "more or less correct". if anything, midpoint is over-shooting in practice. (red dots are the expected path according to midpoint method) ![image](/attachments/9065fa05-815b-44f2-9fe6-ad7d2b2bb592)
216 KiB
Member

w/ the latest commits to ballistics (and y_bows), this issue should be better.

w/ the latest commits to ballistics (and y_bows), this issue should be better.
flux added the
4. step/ready to QA test
label 2024-01-23 23:19:16 +00:00
AliasAlreadyTaken added this to the 1.1.123 milestone 2024-01-24 04:42:04 +00:00
Author
Member

With /create_lag 1000000 1.3 (75% chance of second lag) many arrows seem to disappear similar to how spears do....

With a constant lag I cannot hit a dolphin from up close... For a moment moveresult looked not too bad while shooting at walls... but hitting entities during lag just does not work it seems.

Ballistics 2024-01-23: it's possible to hit mobs during lag 👍
(but particle trace becomes invisible)

Also much harder to hit yourself 👍

> With `/create_lag 1000000 1.3` (75% chance of second lag) many arrows seem to disappear similar to how spears do.... > > With a constant lag I cannot hit a dolphin from up close... For a moment `moveresult` looked not too bad while shooting at walls... but hitting entities during lag just does not work it seems. Ballistics 2024-01-23: it's possible to hit mobs during lag 👍 (but particle trace becomes invisible) Also much harder to hit yourself 👍
Member

arrows are now totally non-physical and will not collide with their "source" (the object e.g. player who shot them).

arrows are now totally non-physical and will not collide with their "source" (the object e.g. player who shot them).
flux removed the
4. step/at work
label 2024-01-28 00:50:04 +00:00
AliasAlreadyTaken added the
ugh/QA OK
label 2024-01-28 12:08:44 +00:00
AliasAlreadyTaken added
ugh/QA NOK
and removed
ugh/QA OK
labels 2024-01-28 12:11:37 +00:00

QA

I can't shoot myself, neither with or without pvp.
However I can't shoot anyone else anymore, regardless of pvp state.

The arrows go straight through. Related to #6118 ?

grafik

QA I can't shoot myself, neither with or without pvp. However I can't shoot anyone else anymore, regardless of pvp state. The arrows go straight through. Related to #6118 ? ![grafik](/attachments/e1fc73df-1492-40ee-a9e5-abb3a9db66f2)
257 KiB
Member

verified that i also cannot shoot another player currently. i can shoot petz just fine tho.

verified that i also cannot shoot another player currently. i can shoot petz just fine tho.
flux added
4. step/at work
and removed
4. step/ready to QA test
labels 2024-01-29 01:52:39 +00:00
Member

i finally figured out why arrows weren't hitting players - players are non-physical. that's what allows other players to walk through you... fixed 509200a43e

i finally figured out why arrows weren't hitting players - players are non-physical. that's what allows other players to walk through you... fixed https://github.com/fluxionary/minetest-ballistics/commit/509200a43edeb37ef3a28ec816278ab70a3beec3
flux added
4. step/ready to QA test
and removed
4. step/at work
labels 2024-02-04 00:36:09 +00:00
Author
Member

ballistics 2024-02-04 on test:
Can't hit myself at all even when I'm trying.
Can hit other players as expected.

Turns out diamond armor can sometimes even one-hit kill a player without armor...

ballistics 2024-02-04 on test: Can't hit myself at all even when I'm trying. Can hit other players as expected. ~~Turns out diamond armor can sometimes even one-hit kill a player without armor...~~
whosit added
ugh/QA OK
and removed
ugh/QA NOK
labels 2024-02-05 16:28:34 +00:00
flux added
5. result/fixed
and removed
4. step/ready to QA test
labels 2024-03-28 20:26:25 +00:00
flux removed this from the flux's TODO list project 2024-03-28 20:26:28 +00:00
flux removed their assignment 2024-03-28 20:26:30 +00:00
Member

this is live

this is live
flux closed this issue 2024-03-28 20:26:38 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#5974
No description provided.