- Home /
How can I create 2D swinging ball?
Hello, everybody.
I am developing a 2D platformer game and I am currently stuck at this basic issue.
How can I create 2D swinging ball in unity? I have searched for an answer for a few hours but all in vain. I am new to Unity and therefore would like to ask you, Unity pros :)
What I want to achieve is a sprite of a ball with CircularCollider2D attached to it so that I can detect collision between it an my player. I don't want it to react to anything else.
It bassicaly should behave like a perfect pendulum, just swinging back and forth. The rope should be a solid object which cannot bend. Also it shouldn't collide with anything at all.
Find enclosed a quick concept sketch (my apologies for my sick MS Paint skills)
Any help would be greatly appreciated! :)

AT$$anonymous$$ I don't have an exact answer, as it would take some time and fiddling, but I recommend looking into sine-waves, as when applied to a rotation of an object, it makes the object rotate in a perfect pendulum.
Answer by Kiwasi · Jul 17, 2014 at 04:29 AM
I would use a DistanceJoint2D to keep the distance.
Use layer based collision detection to prevent collision with anything other then the player
However, if I use DistanceJoint2D, there are energy losses so the pendulum swings slower and slower and with decreasing amplitude.
Your answer
Follow this Question
Related Questions
Grapple and swing/pull mechanic 2 Answers
3D Hook With Swing Physics 0 Answers
my player slips on ground 1 Answer
Affecting angular momentum on bounce 1 Answer
Crushy Bird Game Doubt 1 Answer