Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Does anyone know how to calculate change In direction?
- cs4711673
- Scratcher
2 posts
Does anyone know how to calculate change In direction?
I'm trying to make a racing game where you can drift if you go around a turn if you take a sharp angle. I'm wondering if you can calculate the change in direction or there is something with the directions going from negative to positive that doesn't make it possible. Hope someone can help.
https://scratch.mit.edu/projects/738266583/
https://scratch.mit.edu/projects/738266583/
- deck26
- Scratcher
1000+ posts
Does anyone know how to calculate change In direction?
Certainly possible if I understand the question.
Presumably you're changing direction by less than 180 degrees, at least in the short term. So you can calculate the difference between the old and new direction without worrying about the positive/negative change. Just calculate the difference mod 360 to get a value in the range 0 to 359. That is how far you've turned anti-clockwise but if it's more than 180 you may want to consider it as a clockwise turn by subtracting the value from 360.
Presumably you're changing direction by less than 180 degrees, at least in the short term. So you can calculate the difference between the old and new direction without worrying about the positive/negative change. Just calculate the difference mod 360 to get a value in the range 0 to 359. That is how far you've turned anti-clockwise but if it's more than 180 you may want to consider it as a clockwise turn by subtracting the value from 360.
- Discussion Forums
- » Help with Scripts
- » Does anyone know how to calculate change In direction?