Hi,
Okay so i got a top down car behavior nearly working, I made it using a tutorial with box2d in ActionScript 3.
The link : http://www.emanueleferonato.com/2009/04/06/two-ways-to-make-box2d-cars/
I’m struggling to find the equivalent of some pieces of code in corona.
//This function applies a "friction" in a direction orthogonal to the body's axis. function killOrthogonalVelocity(targetBody:b2Body){ var localPoint = new b2Vec2(0,0); var velocity:b2Vec2 = targetBody.GetLinearVelocityFromLocalPoint(localPoint); var sidewaysAxis = targetBody.GetXForm().R.col2.Copy(); sidewaysAxis.Multiply(b2Math.b2Dot(velocity,sidewaysAxis)) targetBody.SetLinearVelocity(sidewaysAxis);//targetBody.GetWorldPoint(localPoint)); }
How would i get the velocity from a local point of one wheel?
The other sample:
var ldirection = leftWheel.GetXForm().R.col2.Copy(); ldirection.Multiply(engineSpeed); var rdirection = rightWheel.GetXForm().R.col2.Copy() rdirection.Multiply(engineSpeed); leftWheel.ApplyForce(ldirection, leftWheel.GetPosition()); rightWheel.ApplyForce(rdirection, rightWheel.GetPosition());
I don’t really understand how would i do the GetXForm function on a body, looks like it returns a vector but which kind, and what is the equivalent?
Thanks in advance
Max.