# How to make a spring with physics?

0 favourites
• 6 posts
From the Asset Store
Simple yet very life-like rag doll made with Physics!
• hello everybody i need your help i want to make a spring using physics i am not looking to fake it just a simple spring

any help or suggestion is more than welcome <img src="smileys/smiley1.gif" border="0" align="middle" />

• The simple formula for a spring force is F=kx, where k is the strength of the spring and x is the difference of length from a rest length.

Here is a capx of it in action.

https://dl.dropboxusercontent.com/u/5426011/examples20/spring_physics.capx

I also added damping which uses the formula F=-cv, where c is the damping strength and v is the object's velocity along the length of the spring. In the capx the formula looks a bit much because of a vector projection but it works.

• first thanks you very much for your time to set up an example for me realy appreciate it <img src="smileys/smiley20.gif" border="0" align="middle" />

second i want to ask How could i limit the spring movement at certain angle example it move only in 45 degres

i just could not find the formula <img src="smileys/smiley11.gif" border="0" align="middle" />.

when i set the "spring_angle" to constant it became out of control.

• Apply an additional force to move the object to a 45 degree direction:

ex:

Apply force -10*(spring_angle-45) at angle spring_angle+90

10 is the strength and 45 is the target angle in the range of (-180,180).

I suppose it could use a damping force as well...

• i want to thank you for your effort but i puling the triger on the idea .

its a work around the box2d prismatic joint which C2 does not support and cocoojs also.

thanks again for your time and help <img src="smileys/smiley1.gif" border="0" align="middle" /> .

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Very informative all the same! Thanks

• 6 posts