# Create Physics like Zipline

Hello again.

This time, I want to create physics like a zipline. I have created a visual demonstration as shown in the picture below.

As you can see, the height of the Platform 1 will be 5m or anything like that, and it will be taller than Platform 2 whose height could be 2.5, just shorter than the first platform. There will be two poles standing on top of each platform respectively. And there will be one rope or line connecting each pole vertically or diagonally. Creating these objects is not a big deal, I can create them using sprites. Again, there will be one cloth object attached to the first pole on top of Platform 1. It will be at a certain height to that of the player so that the player will have to jump to hold that cloth object.

Now, whenever the object grabs the cloth attached to the rope, it should slide down way to Platform 2 and land there. The cloth object should slide along the path of the rope without making the player fall down. How can I achieve this?

I would consider using physics behaviours, with the following:

• make the rope a static physics object, with layers and masks of 1
• create a wheel as a dynamic physics object, sitting on top of the rope, also with layers and masks of 1
• add physics behaviour to the object the player hangs onto (lets call it a handle), with no layers or masks.

Attach the handle to the wheel with either a wheel joint.

Initially set the wheel as a static object, but change it to a dynamic object when the player grabs hold of the handle.

1 Like

thanks for the answer. Can you please explain how do I make the player grab the object to which it hangs on the zipline, the handle?

One possible way is to check for collision between player and handle, then activate physics behaviour on the player (turn off platform behaviour if it has it) and add a weld joint between the player and the handle.

Thanks for the reply. I did this setup and it is working perfectly, except for one part. When the physics behavior activates on collision with the player for the handle, the handle is falling down a certain distance instead of directly sliding across the diagonal rope along with the wheel. I donâ€™t want it to fall down when it collides with the player. So what could be the possible reason and how can I fix this? Also, when the player reaches the other point, it is slightly titled or rotated. How can I fix these issues?

This is the setup

When the player lands on the other end, it is titled like this, how can I set it to normal?

These are my events:

Instead of setting the wheel as static object initially, I decided to reactive the physics at the start of the scene because the static was not switching to dynamic during. So, I had to use this alternative.

when I mean itâ€™s falling down in the above reply, I donâ€™t mean that the wheel joint is not working. I mean that it is slightly going down before it starts to slide, meaning just a few distances down, not completely gone down.

Set the playerâ€™s mass or gravity to 0 (or as close to 0 as it will go).

Have a play round with the wheel joint settings to see if you can keep the handle on the wheel. Otherwise try a rope or revolute joint.

I think if you set angular dampening to 1, then it should stop the player rotation.

The other thing you could do is when the player releases the handle to to rotate the player back to 0 degrees.

Hello again. I have these events set up.

Now, I got another problem. When the player collides with the handle (ZiplineCloth), only the wheel is sliding down, but the handle and player are freezing at their initial position. The rope is a straight line titled at an angle of 20 degrees.

Physics of rope (dimension: 1315x350 px):

• Type: Static
• Density: 1
• Gravity Scale: 1
• Friction: 0
• Restitution: 0.1
• Liner & Angular Damping: 0.1

For the player of dimension 32x108px:

Density: 1
Gravity Scale: 0
Friction: 0.3
Restitution: 0.1
Linear Damping: 0.1
Angular Damping: 1

For the handle (zipline cloth) 80x100px:
Density: 1
Gravity Scale: 0
Friction: 0.3
Restitution: 0.1
Linear Damping: 0.1
Angular Damping: 1

For the wheel 64x64px:
Density: 1
Gravity Scale: 1
Friction: 0.4
Restitution: 0.1
Linear Damping: 0.1
Angular Damping: 1

Iâ€™ve been tweaking these settings for hours and still couldnâ€™t get the desired results. Sometimes the rabbit is flying, sometimes the handle is flying, and sometimes they are sliding all the way back to the left while they should be sliding towards the right where the rope is inclined at. This is my actual scene setup.

Update: No need to use physics. Physics just messes with platforms.

Solution: Just use the tween behavior like this:

1. Add tween behavior to the player.
2. Add tween behavior to the handle.
3. Add events that check the collision between the player and the handle.
4. Disable the platform behavior of the player on collision.
5. Add a tween to the player and the handle. I would use this:

Tween the position of the player to x: â€¦, yâ€¦ with easing â€ślinerâ€ť over â€ś3000â€ť ms as â€śziplineâ€ť

change the x and y values as per your wish and 3000 is basically 3 seconds converted to ms and zipline is the name of the tween and you are done and done. No need to mess with the physics.

Event name: Tween Object Position

Youâ€™ll find these settings inside the tween object position.

Solution credit goes to WinStreakâ€™s Discord Channel but you can find him on YouTube as well. I like to give credits because heâ€™s the one who found this solution easier.

2 Likes

I agree. It might me fun to create the simulation but unless the games main focus is physics or ziplining, it doesnâ€™t need to be that accurate. The player probably wonâ€™t notice or appreciate the extra attention to details especially if the mechanics donâ€™t work flawlessly. Tweens are simple, reliable, consistent and require fewer resources.

3 Likes

Nice solution. Thanks for sharing it. It goes to show that it doesnâ€™t matter how itâ€™s done, as long as it looks right.

May I suggest you use a target object for the wheel to travel to, and tween to that objectâ€™s position. That way if you move the line, you move the target object too and you donâ€™t have to ferret through the events to update the target co-ordinates.

2 Likes

Tweens are indeed a great way to â€śfakeâ€ť physics. I did a similar method of tweens on a rocket launching up and slamming down.

If you wanted to mess with physics more, I would recommend a prismatic joint on the cloth. Then set the â€śAxis angleâ€ť to be the angle of the zipline. Keep in mind that the speed of the zipline will now change based on the steepness of the angle (which is realistic) but in your game you might want a controllable speed (which the tweens can provide).

1 Like