Script code from this video: new + much easier code by TheJevonjames: var _lerp_speed = 0.1; // how fast to rotate image_angle_ -= angle_difference(image_angle_, direction) * _lerp_speed; //// old code: var angleSet = image_angle_; var faceMinus = abs(image_angle_ - direction); if( faceMinus > 180 ){
there's a better way to do this instead of doing image_angle_ = lerp(image_angle_, direction, 0.1) do var _lerp_speed = 0.1 image_angle_ -= angle_difference(image_angle_, direction) * _lerp_speed
@@1upIndie it lerps to the target angle, but it will always take the shortest route to reach the target angle, instead of doing a full spin when using lerp
@ it’s always good to learn new ways of doing stuff and may make more sense to newbies, so the video does its job! And gives a good platform for my comment to share other ways. You’re doing a great job, keep it up ✌🏻
Oh heck yeah, we're back!
Wow what a great topic and such a great contribution to GameMaker community
Thanks (and for watching)!
Script code from this video:
new + much easier code by TheJevonjames:
var _lerp_speed = 0.1; // how fast to rotate
image_angle_ -= angle_difference(image_angle_, direction) * _lerp_speed;
//// old code:
var angleSet = image_angle_;
var faceMinus = abs(image_angle_ - direction);
if( faceMinus > 180 ){
if( image_angle_ > direction ){ angleSet = -1 * ((360 - image_angle_) + direction); }
else { angleSet = (360 - image_angle_) + direction; }
}
angleSet = clamp(angleSet, 0, 359);
image_angle_ = lerp( angleSet, direction, 0.1 );
i brought your course mam, you should update it
You mean my Udemy course?
there's a better way to do this
instead of doing image_angle_ = lerp(image_angle_, direction, 0.1)
do
var _lerp_speed = 0.1
image_angle_ -= angle_difference(image_angle_, direction) * _lerp_speed
Not sure I get what the other code means. Is it another way to do the lerp code or the "full" way to do the rotation?
@@1upIndie it lerps to the target angle, but it will always take the shortest route to reach the target angle, instead of doing a full spin when using lerp
@@TheJevonjames Damn, just checked this code. It is short, more efficient and more elegant. Thanks, but that makes my video pointless :D
@ it’s always good to learn new ways of doing stuff and may make more sense to newbies, so the video does its job! And gives a good platform for my comment to share other ways. You’re doing a great job, keep it up ✌🏻
@@TheJevonjames 100% agree here! Thanks for showing me the actually easy way.