Quaterion capitalization difference

36 Views Asked by At

I was writing some unity 2d Quatarion Rotation code, but after completing, it gave some errors, then, i capitalized 2 Q's in 2 "quaternion" keywords, and the code started working Just fine. Can Someone please tell the difference between capitalized Q and small q quatarion ( as in Quatarion and quaterion)

i fixed the capitalization in the 2 Q's and the code started working all of a sudden. i have tried searching on google but came short.

Here is the code snippet i wrote:

 private void HandleRandomDirectionChanges()
    {
        changeDirectionCooldown -= Time.deltaTime;
        if (changeDirectionCooldown <= 0)
        {
            float angleChange = UnityEngine.Random.Range(-90f, 90f);
            Quaternion rotation = Quaternion.AngleAxis(angleChange, transform.forward);
            TargetDirection = rotation * TargetDirection;

            changeDirectionCooldown = UnityEngine.Random.Range(1f, 5f);
        }
        
    }

before, the Word Quaterion, then i fixed it. i dont know How it fixed itself, but it did.

1

There are 1 best solutions below

0
djdanlib On

C# is a case-sensitive language.

Unity provides a Quaternion class, which starts with a capital Q. Your code needs to match that exactly in order to use it.

There are some places in C# where there are lowercase versions of capitalized things, such as String being aliased to string, but these are fairly unusual.

You are using other case-sensitive identifiers correctly already, so you're actually used to this. The float type must be all lowercase and Time must be capitalized.

So you are aware of the correct technical language here - Quaternion is a class, which is code, not a keyword, which is a predefined language feature.