Kramuals explained
3 posters
Page 1 of 1
Kramuals explained
So over at the livestream we had a discussion on why kramuals are possible, and why diagonal kramuals aren't, and to so explain this, here I am with the explanation.
So first up, the snippet of code that makes it work:
This code here (and variation of others) exist in bosh's "skeleton" physics. These "skeleton" connections are what makes bosh sit upright, and return back to "normal" position after being left alone for a certain amount of time. For a visual representation, you can turn on contact points with my builds, or use 6.1 contact points to view every skeletal connection bosh has.
What this function does is basically check the distance between each contact point and tries to move him back to the default distance, not position, distance.
What each thing means:
a.x/a.y = is one contact point's coordinates, b.x/b.y = second contact point's coordinates. Everything else isn't as significant.
Now here's how a kramual occurs. Look at these two lines:
This is the initial step for checking the distance between the two points. If the math behing var _loc3 or var _loc2 result in zero, a kramual may occur. Now, assuming that only one of these results in 0, I shal shift your attention to the second part of this code:
Notice how it's asking for _loc3 or _loc2 to be MULTIPLIED by whatever _loc6 is? Don't worry about whatever _loc6 is, we all know anything multiplied by zero, equals 0. So if _loc3 is 0, _loc5 is 0. And if _loc2 is 0, _loc4 is 0. No questions asked.
And finally, the third snippet of code:
Notice how it's trying to add _loc4 and _loc5 to the XY positions of the points? Well, what happens if you add 0 to the coordinate? It doesn't move. And if every point ends up sharing the X or Y coordinate, kramual happens. This doesn't mean that bosh stops moving, we all know you can keep bosh moving in any direction in a kramual. What it means is that the points won't stop sharing the same coordinates, IE that kramual lock we get. Hence why kramuals tend to crash only if rotated, or can only be broken from with a specific well, most commonly the shoulder, because you're forcing a change in the points position.
So why aren't diagonal kramuals possible? Simple. The X or Y points have to IDENTICAL, diagonal lines by default do not share X or Y positions anywhere on the line. The resulting math doesn't cause _loc2 or _loc3 to result in 0, and therefore the skeleton will be able to adjust the points as needed.
So first up, the snippet of code that makes it work:
- Code:
function satisfyDistance()
{
var _loc3 = a.x - b.x;
var _loc2 = a.y - b.y;
var _loc7 = Math.sqrt(_loc3 * _loc3 + _loc2 * _loc2);
var _loc6 = (_loc7 - restLength) / _loc7 * 5.000000E-001;
var _loc5 = _loc3 * _loc6;
var _loc4 = _loc2 * _loc6;
a.x = a.x - _loc5;
a.y = a.y - _loc4;
b.x = b.x + _loc5;
b.y = b.y + _loc4;
} // End of the function
This code here (and variation of others) exist in bosh's "skeleton" physics. These "skeleton" connections are what makes bosh sit upright, and return back to "normal" position after being left alone for a certain amount of time. For a visual representation, you can turn on contact points with my builds, or use 6.1 contact points to view every skeletal connection bosh has.
What this function does is basically check the distance between each contact point and tries to move him back to the default distance, not position, distance.
What each thing means:
a.x/a.y = is one contact point's coordinates, b.x/b.y = second contact point's coordinates. Everything else isn't as significant.
Now here's how a kramual occurs. Look at these two lines:
- Code:
var _loc3 = a.x - b.x;
var _loc2 = a.y - b.y;
This is the initial step for checking the distance between the two points. If the math behing var _loc3 or var _loc2 result in zero, a kramual may occur. Now, assuming that only one of these results in 0, I shal shift your attention to the second part of this code:
- Code:
var _loc5 = _loc3 * _loc6;
var _loc4 = _loc2 * _loc6;
Notice how it's asking for _loc3 or _loc2 to be MULTIPLIED by whatever _loc6 is? Don't worry about whatever _loc6 is, we all know anything multiplied by zero, equals 0. So if _loc3 is 0, _loc5 is 0. And if _loc2 is 0, _loc4 is 0. No questions asked.
And finally, the third snippet of code:
- Code:
a.x = a.x - _loc5;
a.y = a.y - _loc4;
b.x = b.x + _loc5;
b.y = b.y + _loc4;
Notice how it's trying to add _loc4 and _loc5 to the XY positions of the points? Well, what happens if you add 0 to the coordinate? It doesn't move. And if every point ends up sharing the X or Y coordinate, kramual happens. This doesn't mean that bosh stops moving, we all know you can keep bosh moving in any direction in a kramual. What it means is that the points won't stop sharing the same coordinates, IE that kramual lock we get. Hence why kramuals tend to crash only if rotated, or can only be broken from with a specific well, most commonly the shoulder, because you're forcing a change in the points position.
So why aren't diagonal kramuals possible? Simple. The X or Y points have to IDENTICAL, diagonal lines by default do not share X or Y positions anywhere on the line. The resulting math doesn't cause _loc2 or _loc3 to result in 0, and therefore the skeleton will be able to adjust the points as needed.
Re: Kramuals explained
Not sure I toooootally understood that but I think I see why you say that diagonal kramuals are impossible now.
Similar topics
» Kramuals ACTUALLY explained, and why diagonal kramuals are possible
» my first four kramuals :3
» Kramuals hate me
» White screen glitch explained
» my first four kramuals :3
» Kramuals hate me
» White screen glitch explained
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Mon Mar 18, 2024 11:03 am by alpha leonis
» bubblegum - Pure5152
Thu Nov 23, 2023 4:36 am by Rafael
» Started in 2020 - thoughts?
Mon Jul 24, 2023 1:21 pm by cvang
» Hypersonic Motion - Preview and explanation
Mon Jul 24, 2023 12:15 pm by alpha leonis
» Track question
Mon Jul 24, 2023 12:14 pm by alpha leonis
» Line Rider Pointy Wobbly Italian Rat ~ Leonis
Mon Jul 24, 2023 12:12 pm by alpha leonis
» Line Rider Prism ~ Leonis
Mon Jul 24, 2023 12:11 pm by alpha leonis
» Playtime - pure5152
Tue May 16, 2023 4:05 pm by Sheldon
» I coded today!
Mon Mar 20, 2023 6:53 am by jimmysanders