I've modified the TestBed code to store the last selected body, and then apply forces to it depending on keypresses. However, I'm finding that functions like ApplyTorque() are having no effect.
For example, this code applies a fairly large torque when the right arrow key is pressed:
And when I press the right arrow key, Flash Tracer is showing:
rotate CW
torque1:0
torque2:1000
rotate CW
torque1:0
torque2:1000
rotate CW
torque1:0
torque2:1000
Why is the torque being reset to 0 at each step? There's not much in the manual about applying forces and Googling for "box2d ApplyTorque" returned only 3 results, none useful.
For example, this code applies a fairly large torque when the right arrow key is pressed:
Code:
if (Input.isKeyPressed(39)){ // Right Arrow
// todo: rotate CW
if(m_currTest.selectedObject){
trace('rotate CW')
trace('torque1:'+m_currTest.selectedObject.m_torque)
m_currTest.selectedObject.WakeUp()
m_currTest.selectedObject.ApplyTorque(1000)
trace('torque2:'+m_currTest.selectedObject.m_torque)
}
}
// todo: rotate CW
if(m_currTest.selectedObject){
trace('rotate CW')
trace('torque1:'+m_currTest.selectedObject.m_torque)
m_currTest.selectedObject.WakeUp()
m_currTest.selectedObject.ApplyTorque(1000)
trace('torque2:'+m_currTest.selectedObject.m_torque)
}
}
And when I press the right arrow key, Flash Tracer is showing:
rotate CW
torque1:0
torque2:1000
rotate CW
torque1:0
torque2:1000
rotate CW
torque1:0
torque2:1000
Why is the torque being reset to 0 at each step? There's not much in the manual about applying forces and Googling for "box2d ApplyTorque" returned only 3 results, none useful.