Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// @description scr_limit_diagonal();
- /// @param maxSpeed The value to cap the speed at.
- /// @param timeModifier The modifier value for game time, if none then put 1.
- // Calculate Angles
- var angle = point_direction(0, 0, moveSpeedH, moveSpeedV);
- var aa = angle%90;
- var b = 90;
- var c = 180 - (aa + b);
- // Calculate Sides
- var maxSpeed = argument0;
- var timeMod = argument1;
- // Adjust for movement angle
- if(angle < 90 or (angle >= 180 and angle < 270))
- {
- var o = dsin(aa)*maxSpeed; // Opposite Side of the Triangle: Our VSP
- var a = dcos(aa)*maxSpeed; // Adjacent Side of the Triangle: Our HSP
- }
- else
- {
- var o = dcos(aa)*maxSpeed; // Opposite Side of the Triangle: Our VSP
- var a = dsin(aa)*maxSpeed; // Adjacent Side of the Triangle: Our HSP
- }
- // Limit Horizontal Speed
- moveSpeedH = clamp(moveSpeedH, -a*timeMod, a*timeMod);
- // Limit Horizontal Speed
- moveSpeedV = clamp(moveSpeedV, -o*timeMod, o*timeMod);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement