Positioning Problem Solver [ scripting advice needed ]

Hello developers,

Today I come to you with a sort of math/programming problem. I have a rotating set of gears. These gears have rope going between them. The problem is, the aesthetic of the game is “blocky”, so the gears are blocks, as are the ropes. The gears must turn and the ropes must look like they properly reach the gears. As you can see below, the blue points are the ‘points of impact’ the rope has with the gear. The gear has rope rapped all the way around it. As the gears turn, the script must be able to calculate where the new ‘blue points’ are for each frame of this turning movement.

The turning movement must always maintain the same speed, so the calculations must take into account the time between each rendered frame. This is to ensure speed over smoothness.

The depiction below shows how the blue rope impact points might move as the gears turn. The red ropes between the two gears would adjust size and position to reach the proper position on the gears. I imagine that when a certain point is reached, like the rope would appear ‘flushed’ with the top or bottom of one of the gears, the blue point would instantly jump to the next corner. I’m not sure if that makes sense, but I’ll do my best to explain further if requested. I also imagine having these gears be out of sync with one another would look really awkward when it comes to the ropes, so I’ll have the script set the gears to face each other directly upon server start.


Edit: made an animated gif
Gears

I appreciate any and all advice and comments for this.

5 Likes

Please do explain further. Have you tried to make a demo of how this may work? If you have, what are your concerns, and what went wrong?

I am unable to make a demo in Roblox for obvious reasons haha but I can provide a pixelated gif sometime this afternoon if you’d like.

Which part is unclear?

Could you explain in more detail what you mean by the rope appearing “flushed”? The image isn’t as descriptive as I hoped it would be.

Here is an animated gif of what I’m after. You can see that the orange ropes are the parts that move and they stay relatively the same size and orientation. They move to touch the white ‘impact points’ at the corner of each yellow gear. When the gear reaches a flat level where the orange rope is flushed or flat with the gear, the white ‘impact point’ teleports to the next corner in succession. This would be the upcoming corner for the top rope and the going away corner for the bottom rope. The cycle repeats, and the player sees a rope simply winding around 2 gears.

Gif added to OP

The simplest way would be to use two beams.

A beam attached to the two desired edges, and the sides of the cubes between the belt perpendicular to the belt.

Now we can use a while loop with a for loop inside of it.

The for loop could increment a certain amount until the gear is rotated 90 degrees.

Once the for loop finishes, it will repeat with the while loop, setting the gears rotation back to zero.

This will give the illusion that the beam is being set to the new edge, and with it on repeat, it looks exactly like your gif.

6 Likes

Thanks for the input! Simply rotating the gear 90 degrees backwards every time might not have the intended effect, since the sides of the gears are wooden so you’d see the wood grain being reset every turn.

I’d also prefer to use parts if possible. It seems I may be able to make invisible reference points which rotate separately from the gear but at the same speed, and while the gear turns normally the invisible reference points would reset every 90 degrees

Here is the place file if you wanted to look at it.

Square Gears.rbxl (21.1 KB)

Using parts would definitely be harder, not necessarily positioning the belt parts, but making sure their angles line up with other parts of the belt already wrapped around the gear.

3 Likes

Because I just love you so much, I’ve got something in the works for you.

I will let you know when I finish it, and I’ll send the file over.

4 Likes

That’s exactly what I was after! I’ll do my best to implement this now and I’ll reply again if I have any questions. Thank you so much!