9 ms·
Fun side note to this: although bullet collisions are trivial, sword collisions are genuinely computationally complex, in the sense that I’m not aware of a sing
by redistressed 7y ago
Fun side note to this: although bullet collisions are trivial, sword collisions are genuinely computationally complex, in the sense that I’m not aware of a single publicly available game engine that ships with a robust real-time solver for sword-sword collisions.
I find this really interesting because it’s a complete inversion of reality, where bullet impacts are vastly more energetic and chaotic than sword clashes. It tells you something about the scale we play games at, maybe.
I don’t see people talking about it, but this has to be a huge part of why sword combat in video games is so much less explored and well-realized than gunfighting. Figuring out why it’s such a hard problem, and exploring the various workarounds and their limitations, is a fun weekend project if you know a little computational geometry. (And it’s probably the work of a few minutes if you know enough formal geometry, I guess.)
- mwkaufma 7y agoGood note!
- phaus 7y agoDo you happen to know what kind of tech Mordhau uses? Its not perfect but the hit detection seems far better than any other melee combat game I've tried.
- meheleventyone 7y agoMordhau uses a lot of raycasts.
- redistressed 7y agoI don’t know specifically, but the general trick is to get your approximate solve to have the impact happen at a consistent time, since that’s what players have fine-grained control over. Other stuff involved in restitution, like angle of deflection and force at the point of impact, you can basically fudge to be close enough for gameplay purposes. If a game feels really satisfying, it generally means that stuff has been tuned really carefully. (So it is with games.) You work that stuff out with numerical accuracy if you can be careful about when you need to, but since the animations and audio cues need to be carefully tuned anyway, it tends to add unnecessary complexity.
- babuskov 7y agoThe problem with sword combat isn't the computational complexity, but the fact that reporting a hit late is much more noticeable. If you are running across some open space and a bullet hits you, the game can report you being hit 500ms later and it's perfectly fine. With sword, the player can actually see the sword hitting and it has to report the damage at the same moment. A game can compensate by having slower strike animations and preventing players to redirect sword mid hit. Dark Souls 3 does a pretty decent job there - once you press the attack button, you commit to a the attack animation and cannot change or cancel it. So, the receiving end can speed up the attack animation somewhat to compensate and show the sword hit approximately at the same time it hits "on the server". As long as you have good ping, the game feels close to real time - except that opponent attack animations feel somewhat faster than your own (so, harder to dodge and parry).
- redistressed 7y agoAppreciate the comment, but I want stress that the problem really is the computational complexity. (Or at least, computational complexity really is a serious problem.) If everything in your world behaves like a bullet, physics is simple. If everything in your world behaves like a sword, physics is a nightmare. A lot of games with swords literally pretend that swords are made of bullets to get around this. No kidding. To spoil my deep explanation: in the sense games are concerned with, a bullet is a non-rotating length-0 inertially-controlled sword. That doesn’t generalize cheaply.
- nwallin 7y agoSpitballing here. Model a sword as a point of rotation e, (elbow, shoulder, whatever, have the animator figure it out) location of the tip point p, and the linear velocity vector v of its tip. Look at the letter 'F': The elbow is the point at the bottom, the travel of the tip is the top bar, the travel of the hilt (not modeled) is the shorter bottom bar. The travel of the tip is the parametric equation `tv + p`, which defines the line `(tv+p)d + e` You have one line for each sword. Solve for the intersection of the two lines. If t is outside the bounds of your framestep, they do not intersect. Do basic comparisons on the length of the arm/forearm + sword length to figure out if they connect. Bonus: gives you one character slashing the others' wrists for free. Piercing attacks are just hitscan. If you really need to model elbows that are moving (probably only for characters on horseback while galloping) you'll need to parameterize the elbow point. Use the character's velocity vector I guess; I wouldn't do anything more complicated than that. I suppose that also works for combination slashing/thrusting attacks? I'm too lazy to plug that into the line intersection formula, but it seems like a fairly basic linear algebra problem. Unless you're trying to make it super hyper realistic, (don't do that) I don't understand why the computational complexity is a problem.
- gunshai 7y ago>sword collisions are genuinely computationally complex Have you played Dark souls and or Sekiro? I've always been a little curious how FROM accomplishes such a great experience with melee weapons. Also a shout out to Mordhau for similar reasons but with LOTs more people to worry about in a server.
- CoolGuySteve 7y agoI haven't played Sekiro but Dark Souls doesn't really model swords colliding at all. It just plays the animation and allows for the occasional interrupt, like when your sword hand is too near a wall. Your sword slices straight through the enemies and plays a sound effect depending on the hit. But one of the reasons Dark Souls and Demon's Souls feel 'tough but fair' is that the animations are very explicit and mostly uninterruptible by the player. It meant if you made a mistake, it was probably your fault and not the animation or game logic. Demon's Souls actually looked kind of cheap and had janky transitions at the time because of it but the games since then have been getting better at animating transitions between moves. The animation-above-all-else style also leads to some silly interactions with the Havoc physics engine. For example, when you kick through a dead body the rag doll physics accelerate at the speed of the animated player leg causing it to look weightless and kind of ridiculous.
- gunshai 7y ago>Dark Souls doesn't really model swords colliding at all. This is a good point, the only collisions are what you said and animations for parry windows. And yes the rag doll physics in DS games is pretty silly. Have you checked out Mordhau at all? Because that is probably more of the collisions/interactions you were initially referring to.
- jayd16 7y ago>Dark Souls doesn't really model swords colliding at all. Does this really make a difference? There's nothing fundamentally different about sword to sword vs sword to body is there? The anim set makes hits look good even though the impact is not physically calculated for collision angles and impact velocity and such. Perhaps you mean model in this way? Even still, the game has to at least do a hit detection on a deforming hitbox. Do you happen to know how From accomplishes their hitbox animation and collision detection?
- bloopernova 7y agoOfftopic: One day I'd like to see a game that simulates/emulates the multiple layers that go to make up a human character. So you'd start with the skeleton, layer muscles on top of it, then fat layers, then skin. On top of that would come a couple of layers of cloth, then leather, mail, and plate armour. My desire to see this has kind of sprung from mods for games like Skyrim, Fallout: New Vegas, and Fallout 4. Seeing the creativity of modders who make these amazing outfits, armours, and weapons, and wondering how they'd look if they were a single layer on top of other clothing. This, combined with the amazing hitbox work that goes into some games, could be very cool to see. Imagine a character getting hit by an arrow: it would have a vastly different effect whether it hits on a shield, against shoulder armour, or against a helmet. Now imagine if the character had their arms raised for an overhead strike with a sword, and the arrow hit their side or under their arm?
- grawprog 7y ago>Offtopic: One day I'd like to see a game that simulates/emulates the multiple layers that go to make up a human character. So you'd start with the skeleton, layer muscles on top of it, then fat layers, then skin. On top of that would come a couple of layers of cloth, then leather, mail, and plate armour. This is exactly how dwarf fortress works. It's not a flawless system though and it tends to make combat realistically brutal. You can even modify the raws to a pretty large extent and create your own creatures and beings made out of and up of pretty much anything. https://dwarffortresswiki.org/index.php/DF2014:Modding#Modding_creatures https://dwarffortresswiki.org/index.php/DF2014:Modding#Moddi...
- bloopernova 7y agoI had no idea, that's very cool.
- deleted 7y ago[deleted]
- redistressed 7y agoI’ve had this thought. You know what I worry, though— even if I did have a vividly realized simulation of a human body accurate enough to engage in realistic medieval melee combat, wouldn’t I just have her sit at home and write esoteric computer programs? That’s what I do with this one.
- rriepe 7y agoBullets don't have bullet/bullet collisions and they largely don't affect the player model at all. Swords can hit other swords but they also have to convincingly portray the arms, head, torso and legs during any swing or interrupt. Having said all that, I think Jedi Knight 2 is still the best swordplay system. But only because the animations just ignore everything in their way, as a lightsaber would. Each time lightsabers hit there'e either a brief flash of light or a power struggle.
- reificator 7y ago> Having said all that, I think Jedi Knight 2 is still the best swordplay system. But only because the animations just ignore everything in their way, as a lightsaber would. Each time lightsabers hit there'e either a brief flash of light or a power struggle. Agreed, but only if you put the following in your autoexec.cfg: seta helpUsObi "1" seta ui_iscensored "0" seta g_saberRealisticCombat "1" seta g_dismemberProbabilities "1"
- rriepe 7y agoWhile you're at it, bind a stormtrooper spawn to a key too. If you hold it down while your lightsaber is out, you get a whole pile of stormtrooper parts with these options on. Nothing pushed my GeForce 2 harder than that pile of stormtrooper parts.
- DayDollar 7y agoSwords are also hard to control with a mouse and keyboard. Imagine yourself surrounded by a transparent sphere, on which you can paint a point and a line. Where on the sword is that point? How does the point/sword travel along a line? This is not easy to solve. What happens if you shift your perspective after a sword attack is drawn? Can you amplify it by looking away? Can you arrest the motion, by looking towards the executed sword motion.
- B1FF_PSUVM 7y ago(mumble) Nintendo Wii (mumble)
- Impossible 7y agoModern VR motion controls are better. Much of the innovation in physics based gameplay and things like sword mechanics is happening in VR, because the controls are accurate, expressive and low latency. Wii had the idea but lacked real tracking (a smartphone accelerometer can do Wii gameplay better than Wii).
- m-p-3 7y agoEven the improved Wiimote Plus?
- DayDollar 7y agoVR controls are exausting, almost like a real sword battle. Real innovation for gaming is when the controls do not exaust you. What may look like a working system (touch-control) either vannishes after a while (novelty factor wears off) or turns into yet another stone held in a relaxed lapgrip..
- audiometry 7y ago(Mumble) Clang (mumble)
- willmadden 7y agoIn the real world bullet collisions are definitely not trivial. Video games do a laughable job at modeling the ballistics of projectiles. They don't even account for bullet drop. When was the last time you saw a bullet do this in a video game? https://www.youtube.com/watch?v=0ABGIJwiGBc https://www.youtube.com/watch?v=0ABGIJwiGBc If you do some light reading on "terminal ballistics", "experts" can't even agree on the lethality of bullet designs, especially in handguns. People love to assume their models are accurate when they are usually educated guesses with gaping holes. Ballistics is no exception.
- thatguy0900 7y agohttps://youtu.be/cix07R1vlhI https://youtu.be/cix07R1vlhI Arma 3 is the most advanced I know of, accounting for bullet drop and speed loss when passing through different objects with different caliburs
- gallexme 7y agoProject reality, squad even more advanced with wind and smth about earth rotation I forgot the Name of it There's also the ace3 mod for Arma 3 which makes bullets behave more real
- kanaba 7y agoThe Coriolis effect https://en.wikipedia.org/wiki/Coriolis_force https://en.wikipedia.org/wiki/Coriolis_force
- SmooL 7y agoThere's actually many games that account for bullet drop! The article talks about this, but off the top of my head there's PUBG, and any game that involves a bow and arrow as a weapon.
- nine_k 7y agoFirst time I actually saw the bullet drop was the original Quake more than 20 years ago. Set the FOV to some narrow angle to give yourself a sniper sight, go to a long corridor, take a nail gun, shoot horizontally along the length of it. You will see how nails end up below the aiming cross. If it were a rounding error, the nails would end up randomly distributed the aiming cross. Alas, shotgun did not sport the same effect IIRC, though the hit of every individual pellet was accounted for separately.
- boomlinde 7y ago> Fun side note to this: although bullet collisions are trivial, sword collisions are genuinely computationally complex, in the sense that I’m not aware of a single publicly available game engine that ships with a robust real-time solver for sword-sword collisions. That's not a sense in which you can determine the computational complexity of the problem. Perhaps accurate sword combat just isn't very fun. Maybe it makes convincing animation much harder. Maybe it makes controlling the character much harder. Maybe you just don't know that many games. There are plenty reasons that it might be true that no games that you know of shipped with a robust real-time solver for sword-sword collisions other than computational complexity. > I find this really interesting because it’s a complete inversion of reality, where bullet impacts are vastly more energetic and chaotic than sword clashes. It tells you something about the scale we play games at, maybe. Of course the modelling of bullets is also usually extremely simplified in video games. If there is anything we can learn from this I think it's that players prefer games to be predictable and controllable over them being perfectly realistic.
- rossnordby 7y agoI prototyped a physical first person sword fighter doohicky once, so allow me to weigh in: You're both right! I'd point out four big categories of difficulty: 1) Physics. You need a swept collision test capable of handling very high linear and angular velocity of very thin shapes (a sword is not thick, and the tip can move pretty dang fast), and collision response capable of dealing with the results. This is doable- conservative advancement operating on distance functions will work- but working out all the details in a way that makes the final result fast is not easy. A speedy implementation alongside a speculative contact solver can work, though: https://www.youtube.com/watch?v=sfgC_eNx9M8#t=1m20s https://www.youtube.com/watch?v=sfgC_eNx9M8#t=1m20s 2) User interface. A mouse and keyboard struggle to express all the degrees of freedom available to a physical handheld weapon. Swinging using the mouse works okay, but you need to do so in a way that doesn't interfere with camera control, and you need to be able to interrupt and redirect movements at any point, then add jabs, different guards, ... Expressing all of that in a single intuitive interface that doesn't require awkward mode switching is not easy. My prototype had an okay-ish approach, and I think it could still be improved further, but there's no way a mouse-keyboard user would be able to compete with someone of equal skill using VR hand controllers. There's a good reason why melee combat games are so much more common in VR. 3) Graphics. Single planar projections simply aren't enough for first person (especially outside of VR)- it feels like wearing blinders. Even third person doesn't help enough, and seeing your character gets in the way of seeing your weapon and opponent sometimes. Using a nonplanar projection like stereographic fisheye, it starts feeling okay around 160 degrees, though 200+ is nice once you adapt to the mild distortion it introduces. This requires a pretty different approach to rendering (like multiple subviews, direct projection raytracing, vertex warped rasterization, etc.). A couple of examples: https://www.youtube.com/watch?v=jQOJ3yCK8pI https://www.youtube.com/watch?v=jQOJ3yCK8pI https://www.youtube.com/watch?v=mIax_ProQ8c#t=1m4s https://www.youtube.com/watch?v=mIax_ProQ8c#t=1m4s 4) Animation. While achieving a level of animation quality common in early 2000's titles is pretty easy- just have a set of poses for various weapon states to interpolate between, blend in some leg motion, shrug, done- achieving a very high animation quality bar is extremely difficult. Most modern AAA games use massive libraries of mocap data, and in some cases the animations directly drive motion to make everything grounded and solid. For Honor is a good example: https://www.youtube.com/watch?v=4pdcA3mhe0E https://www.youtube.com/watch?v=4pdcA3mhe0E. But in a game allowing total physical control with expectation of proper physical response to every interaction, the mocap coverage requirements explode. You can still do pretty well if you have enough data and put in a huge amount of effort, but at a certain point you start wishing the magical machine learning genie would swoop in and save you. I think all of these things are solvable enough to permit the existence of a game, but they're hard enough that it's not surprising that they are still so rare.
- mntmoss 7y agoThe great lie that games tend to run with is that if they define a sufficiently large lookup table of results, they get a convincing effect without being accurate to any form of reality. This is basically true with almost all character controller behaviors(perfect ability to jump high, sidestep, slide etc. without stumbling) and also with combat results(add enough animations and you have a melee combat system; turn granular physical reactions like bullet impacts into a state change making the target "hurt" or "stunned"). And it's even true of the earliest ball-and-bat games: reduce hitting a ball to a lookup table of trajectories and you get Pong without having any trigonometry in your algorithm. You can define a massive swathe of gameplay code as combinations of "lookup table, finite state, timers, resource counters". This is also true of the physics solvers: define the solver in terms of eliminating all the visibly wrong results(which in the base case means filtering the set of results that contain penetration), and you have one sufficiently good for gameplay. For 2D games this has classically meant solving AABB-AABB movements along 1 axis at a time(i.e. if your raycast is diagonal it's reduced to two one dimensional on-axis movements, which is trivial to compute). Once you want realistic physics as a "special effect" you typically will switch towards using a physics library to provide both solver and colliders, and so as a gameplay programmer you may never have to learn the physics problem in much depth. The video games that really work with physics instead of against them are kind of exceptional, and tend to be categorized as "simulators" - flight sim, racing sim, pool sim, pinball sim. Or they are joke games like QWOP, or at their most fantastic, space games. When we actually simulate anything, the scenario-and-story space tends to reduce dramatically as everything starts converging around the sim's chaos. As we eliminate the sim, more can exist in the designer-fiat space. That's how we can have games about wrestling and swordfighting and yet not really be able to convey the physics or controls of those activities.
- CapsAdmin 7y agoI've toyed with this idea for a bit but gave up because it's difficult to make it feel like you're in control of the action due to the randomness it adds to simply hitting something. The physics itself is not computationally complex as far as I know, but it depends on the amount of detail you want to simulate. I personally think realistic systems like this are fun to make but they can often be frustrating when put in a game. There's an old game called Die by the Sword released in 1998 which lets you control the movement of melee weapons with your https://www.youtube.com/watch?v=DPm3R3eWtA4 https://www.youtube.com/watch?v=DPm3R3eWtA4 The gameplay feels kinda silly, but it works in this game because it doesn't take itself too seriously.
- Craighead 7y agoMordhau
- ironore 7y agoThere is a game that does this. Exanima by Bare Mettle Entertainment. This is my first time with an account here, and I felt compelled to post this.