[testserver] y_bows: it's too easy to hit yourself #5974
Labels
No Label
1. kind/balancing
1. kind/breaking
1. kind/bug
1. kind/construction
1. kind/documentation
1. kind/enhancement
1. kind/griefing
1. kind/invalid
1. kind/meme
1. kind/node limit
1. kind/other
1. kind/protocol
2. prio/controversial
2. prio/critical
2. prio/elevated
2. prio/good first issue
2. prio/interesting
2. prio/low
3. source/art
3. source/client
3. source/engine
3. source/ingame
3. source/integration
3. source/lag
3. source/license
3. source/mod upstream
3. source/unknown
3. source/website
4. step/approved
4. step/at work
4. step/blocked
4. step/discussion
4. step/help wanted
4. step/needs confirmation
4. step/partially fixed
4. step/question
4. step/ready to deploy
4. step/ready to QA test
4. step/want approval
5. result/cannot reproduce
5. result/duplicate
5. result/fixed
5. result/maybe
5. result/wontfix
ugh/petz
ugh/QA main
ugh/QA NOK
ugh/QA OK
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: your-land/bugtracker#5974
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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?
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.
actually i could make it so that
collide_with_objects
is disabled on the first arrow step too, that'd help.If projectile stores who launched it, then it should be possible to check in
on_step()
if the collided object inmoveresult
is the shooter? What happens if you just set_current_velocity(old_velocity)? (assuming engine updates it for you before callingon_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
ugh this makes it so that "i can't hit this mob that's right in front of me if there's lag"
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.
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.
yeah this is exactly what i didn't want to derive myself. it still looks terrible, but not beyond me.
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
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
i spent today understanding the midpoint method well enough to code something, but it remains to be tested.
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?
What if additional lag it's not significant for a limited amount of projectiles? ;p
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 frommesecons_debug
) for 1/3 chance of 1 second lag.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.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.
it's not meaningfully more expensive, if at all - the algorithm is very similar.
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.
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.
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.
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?
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).
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)
w/ the latest commits to ballistics (and y_bows), this issue should be better.
Ballistics 2024-01-23: it's possible to hit mobs during lag 👍
(but particle trace becomes invisible)
Also much harder to hit yourself 👍
arrows are now totally non-physical and will not collide with their "source" (the object e.g. player who shot them).
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 ?
verified that i also cannot shoot another player currently. i can shoot petz just fine tho.
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
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...this is live