- Home /
Create a simple constantly swinging vine/rope
I am trying to recreate this Mario Party 3 minigame. The first thing I want to do is create those swinging vines. I have created a sprite in GIMP and am now trying to make it swing.
My first thought was to simply throw the asset there, put a Hinge Joint 2D at the top of it, rotate it, reduce its angular drag to 0, and let gravity do the rest. Since there is no drag, gravity should be the only force acting on it and the bottom of the vine should oscillate between back and forth, always achieving the height it started at.
This is not what is happening, though. As time goes on, the vine reaches lower and lower heights. What is causing this dampening?
Here is a video I made, which shows a vine at 90 degrees to begin with, but is approaching 45 degrees.
For reference, here is a screenshot of the object (although not at 90 degrees):
What force could possibly be causing the vine to slow down? Please help
Hmm. Interesting. I guess I do not really understand how I could use a spring joint to help simulate a swinging vine. The documentation says that "The Spring Joint joins two Rigidbodies together but allows the distance between them to change as though they were connected by a spring." I only have 1 Rigidbody here (the vine) and I do not really see how swinging from a point could be simulated by a spring.
Could you give me a little more insight as to what you meant?
@cnepoy, sorry for late replay, i edited my answer.
hope it more clear. and I don't know this is best way of doing this but this is one way.
Answer by yashpal · May 15, 2015 at 06:33 AM
hello @cnepoy,
Try spring joint
you might need to change anchor offset position.
Edited:-
steps
you can attached this spring other gameobject which have rigidbody. (else it is always point to point(0,0,0)).
steps:-
1) Take sprite which you want to use as swing.
2) Attach rigidbody2D , and springJoint2D.
3) set parameter as in image. you need to change anchor and position of sprite.
Hope it helps