Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Hello,
So i've been using this library for a while, it's really good. I'm porting my project to this new version, but I'm struggling to make it so the ropes and stuff dont spazz out when the game starts. I used to run the simulation 30 times on the first game frame with high friction, but it doesnt seem to work now.
Any ideas?

Edit: It also seems that increasing the number of points increases the length of the rope. Like, with points set to length/16 I get a much shorter rope than with length/8.

(1 edit)

Hi!

You can run the simulation multiple times by calling system.Simulate(delta); and manually override / temporarily store the friction variable system.frict before that.

The reason the rope with more points appears longer is because every point is affected by gravity, which is dragging the rope down and streching it. You can increase the "stiffness" in the rope's constructor to counteract that. :)

(1 edit)

Hello,
Apologies for the late reply, I've only now gotten back to this.
I still cant seem to stop the ropes from spazzing out. What value should I give the delta, grav, and fric to do it? I've done a repeat(x)verletSystem.Simulate(1) with x being 3000 and even then they arent still when the game eventually loads.

Also something I noticed: when the game starts, the ropes will be fully vertical on the first frame, and then the other end will snap to the position assigned to it. This causes the spazzing to be way worse than it should be. I fixed this by adding a function that puts the rope segments linearly between the start point and the end point, here's the code if you wanna add it to the implementation:

/// @function SetRopePointsPosition();

/// @description Sets the points to be between the first and last point, instead of being straight down. Reduces initial spazzing.

SetRopePointsPosition = function() {

var first = GetPointByKeyword(VI_POINT_INDEX.FIRST).position.current;

var last = GetPointByKeyword(VI_POINT_INDEX.LAST).position.current;

var dir = point_direction(first.x, first.y, last.x, last.y);

var segment = self.length / (pointAmount - 1);

var len_x = lengthdir_x(segment, dir);

var len_y = lengthdir_y(segment, dir);

for (var i = 0; i < pointAmount; i++) {

pointList[| i].position.current.x = first.x + len_x * i;

pointList[| i].position.current.y = first.y + len_y * i;

pointList[| i].position.previous.x = pointList[| i].position.current.x;

pointList[| i].position.previous.y = pointList[| i].position.current.y;

}

}