DarkchaoX10 Posted June 18, 2014 Report Share Posted June 18, 2014 I really need some help with some of the codes from Sonic Reborn! This code: // deacceleration on slopes. if (ground == true && relative_angle > 35 && relative_angle < 335) { if ( action == action_rolling ) { // first check where the character is heading to if ( x_speed > 0 ) // the character is heading to the right { if ( relative_angle < 180 ) // the character is going up a slope... x_speed -= sin(degtorad(relative_angle)) * roll_decc_factor_up; else // the character is going down a slope x_speed -= sin(degtorad(relative_angle)) * roll_decc_factor_down; } else { // the character is heading to the left if ( relative_angle > 180 ) // the character is going up a slope... x_speed -= sin(degtorad(relative_angle)) * roll_decc_factor_up; else // the character is going down a slope x_speed -= sin(degtorad(relative_angle)) * roll_decc_factor_down; } } else { x_speed -= sin(degtorad(relative_angle)) * slope_decc_factor; } } This code is used to deaccelerate on Slopes,but do you maybe know any way to make him keep rolling down slopes like he is supposed to do? I can't figure that out : p Link to comment Share on other sites More sharing options...
thevaleev Posted June 18, 2014 Report Share Posted June 18, 2014 (edited) Actually, this code should work good. With this code player will continuing rolling on steep slopes. Maybe you placed another code in End Step or after this code, and Game Maker reading that code as higher priority. Anyway, if you will not find good resolution, try to put this code in end of End Step Event. // Deceleration based on angle if ( action == action_rolling ) { if ( ((x_speed > 0) && (relative_angle < 180)) || ((x_speed < 0) && (relative_angle > 180))) x_speed -= sin(degtorad(relative_angle)) * roll_decc_factor_up; if ( ((x_speed < 0) && (relative_angle < 180)) || ((x_speed > 0) && (relative_angle > 180))) x_speed -= sin(degtorad(relative_angle)) * roll_decc_factor_down; } Edited June 18, 2014 by thevaleev Link to comment Share on other sites More sharing options...
DarkchaoX10 Posted June 19, 2014 Author Report Share Posted June 19, 2014 Your code seems to work for the rolling BUT Sonic will speedup for watever reasons when walking on loops now... Link to comment Share on other sites More sharing options...
thevaleev Posted June 19, 2014 Report Share Posted June 19, 2014 Your code seems to work for the rolling BUT Sonic will speedup for whatever reasons when walking on loops now... What? This can't be. That code should work only if player is rolling. Link to comment Share on other sites More sharing options...
Light The Hedgehog Posted June 19, 2014 Report Share Posted June 19, 2014 Well since I code differently this may not work for the engine and such but you could adapt it: // Adding motion to rolling // Apply Normal Friction if ((Angle = 0) || (Angle=180)) && (Ground == true) { Speed -= 0.1125*Direction } // Apply Momentum Physics if (Ground == true) { if Speed > 0 && (Angle > 225 && Angle < 360) { Speed += 0.145 } if Speed < 0 && (Angle > 0 && Angle < 135) { Speed -= 0.145 } if Speed > 0 && (Angle > 0 && Angle < 135) { Speed -= 0.145 } if Speed < 0 && (Angle > 225 && Angle < 360){ Speed += 0.145 } } Link to comment Share on other sites More sharing options...
Recommended Posts