Game Development Community

Is the new trigonometry allright? SOLVED

by Eero Karvonen · in Torque 2D Beginner · 05/22/2014 (3:02 pm) · 1 replies

Hi,

I've been spending hours migrating my project to the new trigonometry, faced some oddities (mainly because the documentation seems to be out of date regarding which functions need radians and which degrees), and cannot seem to get past one thing...

First of all, when my circular character is standing on a horizontal platform, the normal from the Box2d collision system is zero, which I don't understand since it should be 90 degrees in the new "mathematically correct" T2D, right?

Now that my character moves on a hill, he should go "along" the surface in the following fashion to prevent hopping,
%moveAngle = mDegToRad( %this.groundNormal - 90 );
%this.setLinearVelocity( mCos(%moveAngle) * %this.xVel, mSin(%moveAngle) * %this.xVel );
where %this.xVel is positive to the right.

It used to work prefectly, now it's hopping down the hills. Can you directly spot a cardinal error?

(The normals are read correctly, if we presume zero is up.)

#1
05/23/2014 (5:51 am)
Problem solved only using degrees.
%moveAngle = -%this.groundNormal; // in degrees
The math docs should be updated on this.

There's still something weird about getting the tangent by negating the normal... But now it works.