Follow an angled path

Just like we were following a path in the last challenge, this one has a wrinkle in it – angled turns.

We’ve got built in commands for turns with pre-prepared settings for 90° turns.

So what do we do if we have a 45° turn?

How about dividing the 90° turn setting in half – because half of 90 is 45!

hardTurn90 / 2

How about a 30° turn? Divide our 90° value by three!

hardTurn90 / 3

How would you do an about-turn – that’s 180°. You could add two 90° values together.

hardTurn90 + hardTurn90

This way, you can build up a whole range of turns which would allow you to follow paths like this:


Using the power of math, you can figure out any angle you need – just divide the 90° value by 90 and then multiply by the angle you need, like this:

hardTurn90 / 90 * degreesYouWantToTurnHere

so if you need to turn by 25, the calculation would be:

hardTurn90 / 90 * 25

You may want to get a protractor to help with angle measuring.