![simcity 5 update simcity 5 update](https://media.contentapi.ea.com/content/dam/gin/images/2017/01/simcity-4-rush-hour-keyart.jpg)
The illistration is not an answer, it is only there to illustrate the concept, you will have to implement the solution in whatever software or library you use. I have added some sliders to let you see the different behaviours. The illistration shows the swing arm in action, but the characteristics of the swingarm is dependent on many many factors The height of the swing arm, the strength of the spring, the damping, the mass of the swing arm, where the spring is mounted on the arm and fixed to the moving trolley. One of the differences between a pendulum and the spring loaded swing arm is that the frequency of the oscillation will change depending on the amount of angular momentum, minimum tension on the spring, and the position of the swing arm. Moving the mouse applies a force in the opposite direction at the top of the swing arm. The dampening (in the demo it is applied at the rotation joint as friction such as found in a rusty joint) is there just to stop it oscillating forever. The spring applies force to return the swing arm back to the upright position. What you are after is a swing arm attached to a spring and a dampener that moves on a trolley. As my native language is not English, please forgive my poor grammar. I have uploaded my implementation, which is a Swift Playground file. There is a screenshot that shows my approach to implement this effect. Thank you for reading my long description, I really appreciate your patience. I really hope anyone with great ability would help me. This helps a lot, but unfortunately the result effect does not seem to be physical at all.Ĭonclusion: after many days’ study, I failed to implement the effect demonstrated in the GIF, and I feel very ashamed of that. A simple function would describe it well: F=1000N×|sin|. When the object tends to be horizontal, the force tends to be big, and when the object tends to be vertical, the force tends to be small. My further solution is that the force that is applied on the object changes with the tilt level. However there is an advance: at least the object is able to stop swinging at last.
![simcity 5 update simcity 5 update](http://4.bp.blogspot.com/-vZk4CZpIYfU/VPpvPZPIVaI/AAAAAAAADvw/opvTpNr2WRA/w1200-h630-p-k-no-nu/SimCity5-O-P.jpg)
This solution is clearly not the ideal one, because when the rotation angle tends to be horizontal, the angular velocity is not high enough and becomes upright slowly. Then I worked out a temporary solution: to multiply the angular velocity by 0.95 every time physics is simulated. Therefore, the pendulum swings and swings, the final physical effect just sucks.
But the result slapped my face really hard :(.
![simcity 5 update simcity 5 update](https://2.bp.blogspot.com/-HNmLFW0JYBo/UfefWzQoI8I/AAAAAAAADSA/qzcBJcnQOCU/s1600/SimCity-2013-Mafia-Gamers-Screenshot.jpg)
But intuition tells me I was not wrong, in fact I did not pinned the object's gravity center to the background, and what I really did is to put the object back to the original position every time physics is simulated. However nothing has proven I am right, because the result I get from SpriteKit's physics engine is that, the object turns out to be a simple pendulum. As a result of combination of the object's inertance and the force, an angular momentum makes the object tilted. Details:Īnd when the object is being manipulated, the point of action is higher than the gravity center. When the object is tilted, its inertance and the force result an angular momentum, which makes the object upright. I have made it a rule that the object's coordinate cannot be changed by the force, so that the object will not be pulled downwards by the force. This is my work: in my project there is an object with an irregular shape, a constant force is applied at somewhere below the gravity center of the object and its direction is downward. Up to now I have finished a similar effect on iOS with SpriteKit, however unfortunately it turns out the result is not pretty satisfying. I am currently working on a project that requires such effect. It is hard to describe in plain text, so I recorded a GIF to demonstrate.