Hello,
I can't get something to work and i was really hoping you guys could help.
What am i trying to do?
I want to create a tree that can wiggle, build from small boxes. So its basically like a vertical stack of 10 boxes all connected by joints.
How am i doing it?
I'm using the RevoluteJoint which i extended with 2 vars a 'springConstant' and a 'springDamping'.
And on a update i run this script:
This does work only the spring is to soft which causes the tree to collapse. Im using a springConstant of 150 and a springDamping of 2.
When i increase the springConstant the bodies start to randomly wiggle really weird.
Did i start of wrong using the revolute joint? Any idea's?
Thanks!
Erik
I can't get something to work and i was really hoping you guys could help.
What am i trying to do?
I want to create a tree that can wiggle, build from small boxes. So its basically like a vertical stack of 10 boxes all connected by joints.
How am i doing it?
I'm using the RevoluteJoint which i extended with 2 vars a 'springConstant' and a 'springDamping'.
And on a update i run this script:
Code:
var Joint:b2Joint = m_world.GetJointList();
for (Joint; Joint; Joint = Joint.GetNext())
{
if(Joint is b2RevoluteJoint){
var rj:b2RevoluteJoint = Joint as b2RevoluteJoint
if(rj.IsMotorEnabled()){
var rja:Number = rj.GetJointAngle()
rj.SetMaxMotorTorque(Math.abs((rja * rj.GetSpringConstant()) + (rj.GetJointSpeed() * rj.GetSpringDamping())));
rj.SetMotorSpeed(rja > 0 ? -100000 : +100000);
}
}
}
for (Joint; Joint; Joint = Joint.GetNext())
{
if(Joint is b2RevoluteJoint){
var rj:b2RevoluteJoint = Joint as b2RevoluteJoint
if(rj.IsMotorEnabled()){
var rja:Number = rj.GetJointAngle()
rj.SetMaxMotorTorque(Math.abs((rja * rj.GetSpringConstant()) + (rj.GetJointSpeed() * rj.GetSpringDamping())));
rj.SetMotorSpeed(rja > 0 ? -100000 : +100000);
}
}
}
This does work only the spring is to soft which causes the tree to collapse. Im using a springConstant of 150 and a springDamping of 2.
When i increase the springConstant the bodies start to randomly wiggle really weird.
Did i start of wrong using the revolute joint? Any idea's?
Thanks!
Erik