d2jsp
d2jsp Forums > Programmer's Haven > C/C++/C# > Ropes And Fanbelts In Unity3d > Ropes In Unity3d
Add Reply New Topic New Poll
mslft
#1 Oct 9 2018 07:01pm
Group: Member
Posts: 2
Joined: Sep 5 2018
Gold: 0.00
Hi guys,

I am working on a hobby project, it's a kind of like a top-down 3D exploration game using the Unity engine. I chose that engine because of C#.

Anyway, I am hoping to get some opinions about which method to use for ropes, chains, and fanbelts. Almost every scene I have includes some type of machinery involving pulleys. Elevators, old-style lineshaft workshops, all of that.

So clearly ropes and rope-like things are an important part of the environment.

I want the ropes to interact with rigidbodies and react to physics. Fanbelts move so fast I could get away with some kind of animated material on a static mesh. But elevator hoists, I really want to get that rickety, old-machinery feel.

I want to expose the mechanical workings, not hide them. That is a large part of the environmental design. So raising a straight rope and concealing the end is out of the question.

I've been looking at buying a few assets but figured I would seek outside opinions first.

Sorry if this is too vague or in the wrong forum. Interested to see what you guys think.

Here are some pictures of the machinery to give an idea:

[IMG]https://imgur.com/CXLrlnz[/IMG]

[IMG]https://imgur.com/60R9j7S[/IMG]

edit: can't seem to get the images to display inline...

This post was edited by mslft on Oct 9 2018 07:17pm
Thrasher66099
#2 Oct 11 2018 10:42am
Group: Member
Posts: 15,582
Joined: Jan 18 2005
Gold: 17,676.53
Unity has a built in physics system which you can add to the gameObjects you need it to work on. Seems like the default physics assets should be plenty for this unless you're trying to add some mechanic that isn't truly lifelike.

As far as the "rickety" feel one thing you could do is add a random timer function that sets itself within some value range (you'll have to play with this to get the right feel). When the timer runs out the gears and elevator movement stops (or slows depending on the feel you want) and a second "stoppage timer" is set with some much shorter value range. When that stops it's calls back to the original timer and the process starts all over again. This continues back and forth until hit FloorReached() or whatever you want to call that method to stop both timers.

If you need more help with some full pseudo code or even real code (used to be a game programmer for a company that used Unity as our game engine) just let me know.
mslft
#3 Oct 12 2018 01:23pm
Group: Member
Posts: 2
Joined: Sep 5 2018
Gold: 0.00
Thank you for the reply. Are you referring to hinge joints? I have heard of people making a "rope" by linking segments together with hinge joints.

I have also heard of using a line renderer for ropes.

An idea I had is to make a curved mesh cable segment, that fits over the top of the pulleys. Then the segment of cable between the elevator car and the hoist is programmatically lengthened / shortened as the car raises and lowers.

That is a good suggestion for adding jitter, thank you.
jacob1818
#4 Oct 15 2018 04:55am
Group: Member
Posts: 12,050
Joined: Sep 30 2003
Gold: 66,649.75
I do find it a bit vague, but English is not my main language so I might have missed some points.

I few tips, if they might help:

As for physics, as said above, the default system should get you covered as a decent (not great, but not bad) solution, unless you want to make a physics based game or something.
However, it will required a LOT of min-maxing/tweaking (at least 1 parameters to min-max/tweak) to get something accurate, at least if the game/project relies on accurate physics. Manual fiddling might just get exactly what you need.

If you feel it's too clunky/bad, an (heavier work) alternative is coming up with the equations from basic kinematics and then make your own physics scripts, animate your models according to them and tweak a whole custom-build physics system.. but this might be a bit overwhelming..

For the behaviors you mentioned, I highly recommend reading and understanding how coroutines work, they pretty much got you covered.

https://docs.unity3d.com/Manual/Coroutines.html
https://docs.unity3d.com/ScriptReference/Coroutine.html
Go Back To C/C++/C# Topic List
Add Reply New Topic New Poll