-
Notifications
You must be signed in to change notification settings - Fork 10
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
Remove kevlar suit from players #2
Comments
You must get the angle using atanx_360_pi... then run some calculations,
|
I did not implement a damage system, but it would be nice to add it as an example. |
Got something that almost works: c951f31 |
Exciting! Haven't looked at the committed code yet |
Yes, I noticed that. That's why it almost works 😄 |
I'm looking at it to see if I find anything but the staggering amount of data coming down the pipe is just staggering. Just by implementing .toFixed(2) for all positions, replacing the use of UIDs for short IDs and ( along with player name mentioned above) would cut it down to less than 20%, for sure. Your player.toJson() could look like this instead:
Which would generate a payload the following payload:
Compared to current:
|
(Errata: forgot to use position.x.toFixed(1) in the last comment and github wont let me update it.) This format would cut the size down even less: .. where The following encode/decode are untested:
|
Btw, sorry to flood the issue with the unrelated topic of message size. Instead, I'd expect some algoritthm to be used to filter out which objects need to be tested: Quadtree for bullet collision detection in javascript: Usable implementation of quadtrees for use in the browser and with Node: https://github.com/p1100i/grid2.js This one has a nice demo to go along 😮 : |
BTW there are some benchmarks and links to JS libraries for collision here: https://0fps.net/2015/01/23/collision-detection-part-3-benchmarks/ |
I kept it simple for now. But yes, it can get out of hand pretty quick with too many bullets. Thanks for the links! |
The hit events should work now, I put it in the master branch. I created a new issue for performance improvements for bullet collisions: #12. |
Thanks, will test and report back in 1 hour 👍 |
Hi, sorry, I'm a bit late. I was only able to test it for a few minutes. Heres a screenshot showing the problem: This problem can be reproduced by firing on the very edge of the enemy. If my assumptions are right, it seems the clients currently have authority to detect hits independently from the server? Is this a good idea? I'm guessing them that the fix would be to always rely on the server to authorize hit events. @arjanfrans , @asdfuken , @redblobgames what do you think? |
@jgamedev You are correct. If the client hits someone, it will hit optimistically, not waiting for a server response. This is indeed not a good idea. The client should be corrected by the server. I am wondering, does the client even need to perform detection, or just always wait for the server? |
I believe the most optimistic your clients could be is to render bullet movement locally, but hits (and the corresponding bullet suppression) should definitely fully rely on server commands only. See the comment from user PrimeDerektive in a similar discussion here: Also if the user renders bullets optmistically ( which I definitely think it shoud) and the server doesnt correct bullet position at least once, I think could cause the opposite problem where hits that are only aknowledged after the bullet already went past the user, due to a late server response. Not 100% sure what to do there... 😕 |
@jgamedev The “standard” answer is to never trust the client, and do everything on the server, but I've seen other architectures that work too. It depends on the game. Client hit detection sometimes feels better because there's no lag and it can be pixel perfect. |
@redblobgames thanks for commenting! I think that a hybrid approach would be to allow the client to optimistically remove bullets for unconfirmed hits, but maybe not render the damage sprite? This could prove to be a nice balance, because it would prevent the annoying body traversing bullets scenario, at the same time that it doesn't completely misinform the local player, since he will not see rendered damage unless the server confirms it. Bellow are a couple of possible limitations that could potentially arise from using this hybrid approach: Resurrecting bullets anomaly:Once removed by the local user the bullet should be gone forever and further references to the same bullet should be disregarded in order to prevent reappearing bullets. Damage by invisible bullets anomaly:Say i have 2 enemies one is in front , the other enemy is a little behind. End result: Because the bullet has already been optimistically removed by the local client, damage will be a applied to the second enemy but without a bullet visually hitting him. So in this scenario, from the perspective of the local user, he sees enemy 1 intercepting the bullet while enemy 2 is the one actually getting and displaying the damage. Thoughts? |
From my test it seems that players are not currently affected by bullets
Can you give me some orientation on how to properly add some sort of damage system to the engine?
I appreciate any help.
The text was updated successfully, but these errors were encountered: