Freaking Springs...

Jun 17, 2010 at 12:02 AM
Edited Jun 17, 2010 at 12:03 AM

I've been trying to get springs to work in my small test engine. Now here's the problem.... they ain't working. They either don't work at all, or work and make the objects go apesh*t and crash the engine... Here's the code I'm using:

SpringFactory.Instance.CreateFixedLinearSpring(ps, Body, SpringStartPosition, SpringEndPosition, 100, 50);

SpringStartPosition is the location in the world where the object is located + an offset. Say i have a square at point (100,100), the SpringStartPosition will be at (150,150) (the middle of the square) and the SpringEndPosition will be at (150, 50)... is this correct? I don't quite understand the springConstant and dampingConstant.... and i've tried multiple values from 1,5 to 100000, 50000. Nothing seems to work for me. Any ideas?

Thanks! Tristan.

PS: In the above code, ps is my physics engine instance and Body has been created, along with geometry and both have been adding to the phys engine.

Jun 17, 2010 at 6:44 AM

I think you are going to want to make sure to use world coordinates when creating that spring.  You want to use the get WorldCoordinates function on those local points on the square to do it properly.  A spring tieing a body to itself would indeed cause it to go crazy.  It's late here, so I could be way off.