- Home /
C sharp + farseer question in Unity3d
Hi!
First of all, there is a great tutorial to make a top down car in box2d here: great tutorial A farseer conversion of this, here (bottom of the page): c sharp conversion
I want to do it within Unity, but this procedure makes me totally stupid:
private void killOrthogonalVelocity(Body body)
{
Vector2 localPoint = new Vector2(0, 0);
Vector2 velocity = body.GetLinearVelocityFromLocalPoint(localPoint);
Transform tmp;
body.GetTransform(out tmp);
Vector2 sidewaysAxis = tmp.R.Col2;
sidewaysAxis = Vector2.Multiply(sidewaysAxis, Vector2.Dot(velocity, sidewaysAxis));
body.LinearVelocity = sidewaysAxis;
}
My question is: Can "Transform tmp;" be done with Matrix4x4 calculations, or what a pig tale is this? (sorry for my basic english, again...)
It is incredibly easy to do car games in Unity. Because Unity is built to do that. You will not need to do ANY calculations like this.
On the other hand, it is almost impossible to translate strange code like this "to use in Unity" ... you know?
Certainly you can do every conceivable transformation, matrix transform, quaternions etc in Unity - just glance at the documentation.