Degtorad

From Game Editor

Jump to: navigation, search

double degtorad(double a);

degtorad returns the radian equivalent of angle a. Useful as certain functions, like cos, sin, and other trig functions require radian input.


Example: Keep the nob of an on screen joystick in a circle around the base. Uses distance, direction, cos, and sin.

joystickNob -> Draw actor -> Script Editor

if(distance(x,y,joystickBase.x, joystickBase.y)>50)
{
    double ang = degtorad(direction(joystickBase.x, joystickBase.y, x, y));
    x=joystickBase.x-cos(ang);
    y=joystickBase.y+sin(ang);
}