Jump to content

Making a Mistborn Video Game in Unity – Physics & Math of Allomancy


Artemos

Recommended Posts

24 minutes ago, Calderis said:

This thread by @Pagerunner and it's doc may help you out.

 

That was one my favorite posts. I definitely agree with his final point that Allomancers can only define the percentage of their maximum Push strength. The burn rate, directly controlled by the player, ranges from 0% to 100% to give the same effect.

Link to comment
Share on other sites

Aw, yes, I love me some math. I unfortunately don't have time to dig into it all right now. But, in case you haven't finished the Impossible Physics thread, I don't think I updated my first post to include a later development we worked to. I changed my mind to: force is inversely proportional to relative velocity (as opposed to an arbitrary cutoff where you can't push beyond a certain speed). So you can ramp the coin up pretty quick, and then the force drops to almost negligible before it has enough time to push back on the Allomancer.

But I kept it all to variables for a reason - I don't have the patience to actually come up with coefficients and exponents. So, more power to you, and best of luck! Looking forward to seeing more about it as you progress.

Link to comment
Share on other sites

Thanks! Making the force inversely proportional to the target's relative velocity feels too complex for what (in my mind) should be similar to magnetism, gravity, or any other force ruled by an inverse-square law. The relative velocity idea sounds like it would mimic the books pretty well, but without context I can't think about it further. Do you have a link to the post?

Link to comment
Share on other sites

This is amazing, the amount of work you put into this is incredible. Is there any way you could let some of the shard demo this with out breaking copyright laws? 

Also, how do you think that emotional allomancy would work in a video game? I am not much of a gamer or a programmer, but I am excited to hear what your plans are. Thank you for your great contribution to the Shard.

Link to comment
Share on other sites

47 minutes ago, Ark1002 said:

What exactly are the laws you would break if you sold it? Do you just need to ask Brandon or is there something I haven't thought of?

There's already been an officially licensed  Mistborn game in development. There's been very little news about it, so it probably won't be happening for a few years, if ever. It would be illegal because Mistborn isn't my property, and trying to profit from it would be a breach of copyright. This is just a fan game, so if I ever release it, it would be for free.

10 hours ago, Gasper said:

This is amazing, the amount of work you put into this is incredible. Is there any way you could let some of the shard demo this with out breaking copyright laws? 

Also, how do you think that emotional allomancy would work in a video game? I am not much of a gamer or a programmer, but I am excited to hear what your plans are. Thank you for your great contribution to the Shard.

I could probably put up the current build of the game up for download through my Dropbox. It would be nothing more than a physics demonstration, but I do think many people would still be interested in that. I'll see what I can do.

Regarding emotional allomancy: Some facets of Allomancy work better in the medium of a game than others, namely iron/steel, pewter (as a health/armor system), and tin (think like Witcher senses). The Mental metals would be interesting, but I don't know how I'd implement them. The easiest thing to do would be to make the player a coinshot/lurcher hybrid with only Ironpulling and Steelpushing. I think adding any other metals might be too ambitious.

Thinking of the Witcher reminds me of the Axii sign, which could provide a similar effect - Soothing or Rioting enemies to distract them, delay them, or turn them on their allies (in the case of Koloss and the like, or with duralumin).

Link to comment
Share on other sites

My brother played around with a very similar, but much more limited idea for one of his classes. The big challenges, as I recall them, were the physics of Steelpushing and Ironpulling (which you are already aware of) and how they work in Unity, and the visuals - how do you picture things like emotional Allomancy, for example. It's a big undertaking, but you've got some thinking done, which is good. I would only advise you to start small and see how the scope shapes up.

Link to comment
Share on other sites

13 hours ago, Artemos said:

Thanks! Making the force inversely proportional to the target's relative velocity feels too complex for what (in my mind) should be similar to magnetism, gravity, or any other force ruled by an inverse-square law. The relative velocity idea sounds like it would mimic the books pretty well, but without context I can't think about it further. Do you have a link to the post?

I don't remember where the conversation went down - looks like it wasn't in the thread, but it might have been on Discord (where the conversation started) or possibly on Reddit. Technically, my original idea had force as a function of velocity - it was just a step function, transitioning from 1 to 0 when velocity reached the maximum. Making it an inverse relationship (which is more qualitatively so; not necessarily 1/x, but even a decreasing exponential would fit), something continuous, makes for a model with no on/off oscillation at the 'maximum velocity,' which I found a lot cleaner.

Link to comment
Share on other sites

18 minutes ago, Pagerunner said:

I don't remember where the conversation went down - looks like it wasn't in the thread, but it might have been on Discord (where the conversation started) or possibly on Reddit. Technically, my original idea had force as a function of velocity - it was just a step function, transitioning from 1 to 0 when velocity reached the maximum. Making it an inverse relationship (which is more qualitatively so; not necessarily 1/x, but even a decreasing exponential would fit), something continuous, makes for a model with no on/off oscillation at the 'maximum velocity,' which I found a lot cleaner.

Yeah, having a discontinuity in the force formula was something I wanted to avoid at all costs. I think the coin's distance from the allomancer accounts for the dramatic decrease in force, rather than its high velocity. Pushing on an anchored coin keeps it close to the allomancer for a reasonably long time, while pushing on an anchored coin will quickly become very distance from the allomancer. In the first case, the coin has a low/zero velocity, low distance, and high force on the allomancer, while in the second case, the coin has a high velocity, high distance, and low force on the allomancer. The distance between the coin and the allomancer already accounts for the difference in forces between an anchored and unanchored coin.

Sorry if that's a bit wordy. In the original post, I say,

Quote

This last bit about the distance is key. If an Allomancer is falling through the air and throws down a coin, the coin quickly falls further and further down. The Allomantic Force quickly becomes very small. Only once the Allomancer falls further and is near the coin – now anchored to the ground – does the distance stay small enough for the Allomantic Force to be large enough for a long enough time to scale a building.

Does that make sense? The 1 / r relationship provides a similar effect as an inverse relationship with the velocity.

Link to comment
Share on other sites

1 hour ago, Gasper said:

For things like emotional allomancy, have you thought of using a mechanic that is more like a force field that you can narrow to one person or leave on for a large group of people?

Haven't thought about it. For pushes and pulls, I plan on eventually recreating Wax's steel bubble, with which the player can apply a weak push or pull to all metals around them. As of now, targeting multiple metals gives the player a weaker push for all of them (pushing on 3 targets gives 1/3 a push for each, giving a net force that is equal to pushing on 1 target with 100% of the force). If I did implement emotional allomancy, I would probably use the same strategy: your maximum Sooth strength is at 100% on one target, at 1/2 strength on two targets, or at a weaker strength for a general "bubble" of soothing.

 

2 hours ago, Argent said:

My brother played around with a very similar, but much more limited idea for one of his classes. The big challenges, as I recall them, were the physics of Steelpushing and Ironpulling (which you are already aware of) and how they work in Unity, and the visuals - how do you picture things like emotional Allomancy, for example. It's a big undertaking, but you've got some thinking done, which is good. I would only advise you to start small and see how the scope shapes up.

The physics where definitely difficult. The basics of pushes and pulls weren't actually all that hard (Unity's physics are good enough for that), but the getting the Allomantic Normal Force (and the Kinetic Energy idea I mentioned in the post) to work was much more complex. My final strategy was to go frame-by-frame, comparing the target's actual acceleration to the expected acceleration it should have experienced from the Allomantic Force. The difference between the two is sent back to the Allomancer. Essentially, the force that the target experienced to resist the Allomantic Force is sent back to the Allomancer. I hope that makes sense. I'll probably document all this better in my code soon.

Link to comment
Share on other sites

Have you checked the README? I wrote all the controls there. But yes, I'll add tutorials and improve the controls in time. It's very bare-bones at the moment.

Today I've been trying to make the player control the magnitude of the force of the push, rather than the percentage of their maximum push. It feels a lot more intuitive and easier to control, but still has a few kinks to work out. I'll probably commit it tomorrow.

Link to comment
Share on other sites

Mental allomancy could have some interesting combat applications for a game. I'd be thinking something like the rage/pacify spells from Skyrim.

As to the rest, wow. This is genuinely amazing. Keep up the good work mate, I can't wait to see what else you come up with.

Link to comment
Share on other sites

@Artemos Did you give any thought to my e^-r concept for range? Assuming you saw it. It's probably unnecessarily complex for a game. I think Phantine felt it was unnecessarily complex for an equation. :)

But it (1) avoids the issue of 1/r^2=infinity at r=0 (e^0=1) and (2) doesn't require a max range, which feels kind of clunky to me for "scientific" equation. Practically speaking, it can be made very similar to a linear relationship, depending on how you scale it. Just doesn't have a limit, and gives more weight to closer ranges. For example, something like e^(-r/20) gives you something practically similar to the 50-r that you're currently using... just a bit below the line until 40m and still at about 10% at 50m. Effectively 0 around 80m or so.

I'd be curious to see how that feels versus the linear or inverse square relationships. :)

Link to comment
Share on other sites

Here's an graph of the three models for distance layered over each other. Indeed, the exponential looks a lot like the linear relationship, but doesn't equal 0 at the max range, which I like.

18 minutes ago, Jofwu said:

But it (1) avoids the issue of 1/r^2=infinity at r=0 (e^0=1) and (2) doesn't require a max range, which feels kind of clunky to me for "scientific" equation. Practically speaking, it can be made very similar to a linear relationship, depending on how you scale it. Just doesn't have a limit, and gives more weight to closer ranges. For example, something like e^(-r/20) gives you something practically similar to the 50-r that you're currently using... just a bit below the line until 40m and still at about 10% at 50m. Effectively 0 around 80m or so.

(1) I don't really think this is an issue. Look at magnets, which also obey an inverse square law and have the same "1/r^2 -> infinity as r -> 0" property. The Allomantic Force will never approach infinity in the same way that the force between magnets will never approach infinity. You can hold them close together, but unless you have a hollow magnet, their centers of mass won't overlap, and the distance will never get near zero. Still, it does get extremely high, which is a flaw with using it for Allomancy.

On a somewhat related note, I subscribe to the theory that Allomancy doesn't actually push and pull from the center of mass. Rather, Pushes and Pulls operate like gravity and magnetism: Each tiny bit of the Allomancer has a mass/charge that pulls on each tiny bit of mass/charge of the target. In sum, it looks like the Allomancer's center of mass is pulling on the target's center of mass.

(2) A hard, exact, max range definitely bothers me. There's no force field in the real world that at 49.99 meters "has a nonzero force" and at 50.01 meters "has a zero force". I really want the force to approach zero, not equal zero, at the max range.

18 minutes ago, Jofwu said:

I'd be curious to see how that feels versus the linear or inverse square relationships. :)

I'll put the formula in the game and get back to you on how it feels.

Link to comment
Share on other sites

Yeah, no technical issue with an actual r=0 case, but just the practical issue of very high values relative to some short distance away.

I see you made use of that "16" factor again. Love it.

Concerning center of mass... Yeah, I mostly agree. I think Brandon imagined something more like center of mass, but practically speaking that just doesn't make sense. You can't apply a point force on somebody in real life; you have to distribute it across... something. The biggest problem with the "gravity" approach is that characters describe whiplash. So I've kind of been working under the assumption that the "Allomantic charge" isn't evenly distributed throughout the body. Trying to tackle that in more detail is getting into the weeds perhaps. :)

I don't really like the Allomantic Normal Force concept, but I guess if that's the clearest way to make the actions seem natural then it's the way to go.

I'm curious though. Did things not work out as u/phantine predicted without ANF? His idea relied too much on force dropping off with distance faster? Seems like coins accelerating to 120 m/s in one frame should give a lot of recoil.

Link to comment
Share on other sites

29 minutes ago, Jofwu said:

The biggest problem with the "gravity" approach is that characters describe whiplash. So I've kind of been working under the assumption that the "Allomantic charge" isn't evenly distributed throughout the body. Trying to tackle that in more detail is getting into the weeds perhaps. :)

I think it's similar to the popular topic of Kaladin nearly blacking out/experiencing whiplash while Lashing. If these magics existed in the real world, the whiplash wouldn't exist. All your internal organs would experience a uniform acceleration/change in acceleration, but it just feels intuitive for the body to experience whiplash and that's how Brandon wanted it to feel. And yes, that's definitely getting into the weeds.

29 minutes ago, Jofwu said:

I don't really like the Allomantic Normal Force concept, but I guess if that's the clearest way to make the actions seem natural then it's the way to go.

I'm curious though. Did things not work out as u/phantine predicted without ANF? His idea relied too much on force dropping off with distance faster? Seems like coins accelerating to 120 m/s in one frame should give a lot of recoil.

Ehh, that quick recoil of the coin would exist with or without the ANF. If anything, the ANF would increase it as the coin is resisted by drag.

Without the ANF (or at least some system that gives the player a stronger push from an anchored target), pushing overall feels much less impactful, especially when bracing yourself against a wall and pushing against something.

Honestly, it is hard to tell if anchored pushes are stronger because the distance stays smaller than that of unachored targets or if it's caused by the ANF. It's certainly possible that the distance is all that matters. I'll add an option in the settings to enable/disable the ANF.


What follows is me completely misunderstanding you and writing out a whole dang response to something completely irrelevant. Oh well. Not gonna delete it because I spent so much time in it and there's still a few interesting tidbits. Here's me arguing against an inverse relationship between force and velocity:


The ANF is definitely the cleaner calcuation-wise and works well in-game.

The velocity strategy was much more difficult to program effectively and had strange edge cases, such as when you begin pushing on any target that isn't moving (anchored or not).

  1. A coin is sitting on ice. Its velocity is 0.
  2. The Allomancer begins pushing on it.
  3. The coin is not moving, so it receives a lower percentage of the push than the Allomancer.
    1. Specifically, it would receive none of the push because its velocity is 0 (using a some kind of simple relationship).
  4. The coin receives a lower percentage of the push, so it accelerates less.
  5. It accelerates less, so it has a lower velocity.
  6. etc. etc. etc.

Already from (3.), There's a sort of feedback loop that occurs whenever a target is stationary. If a target isn't moving, it mustn't need any of the push, so it doesn't accelerate, regardless of how anchored it is. You'd have to "push on it a little" to see if its velocity changes, then move it back to where it was and give it an appropriate percentage of the force. It's a lot more complex than the Allomantic Normal Force.

In other words, you would have to be constantly checking if the target's velocity is where it's at because it is anchored/partially anchored or simply because you haven't pushed on it hard enough yet.

I know that there are solutions to this and it would be possible programming-wise to create this effect. But, the simple fact that you would have to program edge-cases for this feels unnatural.

The reason I like the ANF is because it mimics physically pushing on something in real life from a distance with a pole. You push on the pole, which pushes on the target. If the target can't move, the target resists the pole's push, which resists back to the Allomancer.

  • If you're falling down and you jab the pole downward and it just slices through the air, you'll accelerate up a little, but hardly enough to slow your fall.
  • If you're falling down and you jab the pole downward and it hits the ground, you'll slow, then stop, then begin climbing up.

It's a lot more elegant (in my opinion) than making the force a function of velocity/relative velocity.

Link to comment
Share on other sites

4 minutes ago, Artemos said:

think it's similar to the popular topic of Kaladin nearly blacking out/experiencing whiplash while Lashing.

This only happens with sudden and extreme changes in direction under multiple lashings, and actually makes sense when taking momentum into account. 

In the vast majority of instances its just a direction change in the way someone falls. 

Link to comment
Share on other sites

 

5 hours ago, Artemos said:

The velocity strategy

Misunderstanding or not, it was interesting to read what you worked through!

I assumed at first you were referring to Pagerunner's thing, where velocity is part of the equation, but this sounds different. Almost opposite? If you're looking at relative velocities I don't see why you need to keep track of where the velocity is coming from or whether one thing or the other. 

If I recall, I think my concept using his idea was that the equation would have an "e^-v" term since it works very similarly to distance. That way you get 100% force when the Allomancer and coin are stationary relative to one another. It diminishes as the coin accelerates away. Then it hits a wall, velocity is suddenly zeroed out, and force instantly jumps from some lower level back to 100%. Practically speaking, I don't know how computationally intense that would be... to keep track of the velocity of every metal object relative to the Allomancer. And I don't know that it would yield results that feel right.

I can't put my finger on why ANF bothers me. I'll have to think about it.

I haven't had a chance to test the game out, but I'm really itching too now. :D

5 hours ago, Calderis said:

This only happens with sudden and extreme changes in direction under multiple lashings, and actually makes sense when taking momentum into account. 

In the vast majority of instances its just a direction change in the way someone falls. 

This is not the right thread to debate it, and I don't know that you want to go down that road. But I feel quite strongly that isn't how it works. Gravity, including sudden or rapid changes, can't be felt. The only case where you feel something with Lashing is with the air resistance produced. The simplest issue you deal with is that at terminal velocity under multiple Lashings (no sudden changes here) you feel the full weight of those Lashings by means of strong wind blowing against you. Lashed 5 times and currently at terminal velocity? It feels like wind is blowing against you so hard that you're being accelerated by 5Gs.

Link to comment
Share on other sites

3 minutes ago, Jofwu said:

I assumed at first you were referring to Pagerunner's thing, where velocity is part of the equation, but this sounds different. Almost opposite? If you're looking at relative velocities I don't see why you need to keep track of where the velocity is coming from or whether one thing or the other. 

If I recall, I think my concept using his idea was that the equation would have an "e^-v" term since it works very similarly to distance. That way you get 100% force when the Allomancer and coin are stationary relative to one another. It diminishes as the coin accelerates away. Then it hits a wall, velocity is suddenly zeroed out, and force instantly jumps from some lower level back to 100%. Practically speaking, I don't know how computationally intense that would be... to keep track of the velocity of every metal object relative to the Allomancer. And I don't know that it would yield results that feel right.

After I realized that I misunderstood you, I didn't put much effort into making it make sense. Regardless, the exponential relationship with velocity sounds very interesting. I'll try it out eventually. I won't be able to work on the game over the weekend, though.

 

The way I was originally thinking of the relationship between force and velocity was sort of like this: There is a finite quantity of kinetic energy that can be added to the target-allomancer system each frame. The distribution of this energy depends on their velocities, so if the target and allomancer weighed the same and accelerated equally they would each receive 50% of the energy. If one had a velocity of 0, it would receive 0% of the force and the other would receive 100% of the force. That was what I tried to explain in that comment, and it would be difficult to implement. The exponential relationship certainly sounds a lot more reasonable.

 

It also wouldn't be that computationally intensive to keep track of every metal's velocity. I know that because... I already do that. It's actually part of how the ANF is calculated. I'll probably edit the original post or comment the code to explain the specifics.

Link to comment
Share on other sites

Sounds awesome.

And I finally got a chance to play around with this. It's a BLAST! Really well done so far. :)

The controls aren't easy to grasp... but it's so much more intuitive than I would have guessed.

Do the buildings have less friction or something? Seems like it's harder to jump from a Pushed coin on top of them. Also, is it possible to target more than one thing for a Push or Pull? Thought I saw that in one of the gifs, but I can only seem to do one for each.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...