A Humble Mathf.Sinner Repenting for not reading the advice to read Unity Docs

Hi Everyone,
I am a humble Mathf.Sin-ner repenting S.Hubbard’s advice to read Unity Docs about Mathf.Sin. But went ahead and coded in C#, the word of our Lord, Unity.

[Update] The following is a narration of my experience, for I fear retribution if I do not spread the word of our Lord’s miracle.

Somehow my Shooter script was spewing bullets all bunched together like grapes. Couldn’t figureout why or how. I spent nearly a day to figure it out. By noon, my brain was exploding, :exploding_head: so I thought I would take a nap. But before going to bed, I prayed to Unity God to give me a SIGN, a Miracle. During my nap, God appeared in my dreams and told me -“Read Emmanuelle and it shall be revealed to Yee”. I woke up drenched in sweat but couldn’t quite figure out what he said. :roll_eyes:

So I went on with some more debugging later that noon and figured –
Mathf.Sin() was expecting a float in RADIANS. So current angle had to be converted using Mathf.Deg2Rad

At that point I read the docs and I was like OMG. Cuz then it dawned to me that our Lord was telling me not to “Read Emanuelle” but “Read the Manual”. :cry: Because I didn’t read the Docs, I was using Mathf.Rad2Deg instead.

Peace be with yall.

Because of the Nightmare of debugging for a full day with float values representing both Radians and Degrees, I decided to create a Utility class for Radians & Degrees

public class Degrees {
    public float value;

    public Degrees(float value) {
        this.value = value;
    }

    public static implicit operator Degrees(float value) {
        return new Degrees(value);
    }

    public static implicit operator float(Degrees degrees) {
        return degrees.value;
    }

    public static implicit operator Radians(Degrees degrees) {
        return new Radians(degrees.value * Mathf.Deg2Rad);
    }
}

Now it is possible to do this, without any confusion if the float represents degree or radian

Radians rotation = new Degrees(12f)

Privacy & Terms