Kramuals explained
Page 1 of 1 • Share •
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.000000E001;
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.
_________________
LR Subreddit http://www.reddit.com/r/linerider/
Discord Group https://discord.gg/0ggPNq98iruWoixw
OpenLR https://github.com/kevansevans/openLR
My Tracks https://www.youtube.com/playlist?list=PLLLsxGACxkK8PYsamGoFkDABMHxahqF1G
[senpai] kevans Member
 Stay in your coma
Re: Kramuals explained
Not sure I toooootally understood that but I think I see why you say that diagonal kramuals are impossible now.
_________________
Support My Art
A playlist of my best tracks
To keep up with what I'm up to in the world of Line Rider, follow me:
My Twitter  My Tumblr  My Twitch  My Facebook Page  My Instagram
(You can also follow my patreon and see all public posts completely for free)
rabid squirrel Member
 I'm the artsy guy round here
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum


Fri Dec 14, 2018 9:22 pm by Arglin
» BACON ™
Mon Dec 10, 2018 7:35 pm by Hanuman
» Interrobang V  The Series Lives On
Mon Dec 10, 2018 10:49 am by Arglin
» In my time of need
Tue Nov 27, 2018 3:23 pm by Hanuman
» Gypsy  iPi
Tue Nov 27, 2018 6:58 am by Rafael
» LAMB
Sun Nov 25, 2018 12:17 am by anton
» Escape  Late Submission for the Destinations Competition
Wed Nov 21, 2018 3:25 pm by Arglin
» Carnival of Rust and 2 other tracks
Tue Nov 20, 2018 3:33 pm by Toivo
» Endless 1.5
Mon Nov 19, 2018 8:46 pm by Hanuman