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.
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
Stringbeing aliased tostring, but these are fairly unusual.You are using other case-sensitive identifiers correctly already, so you're actually used to this. The
floattype must be all lowercase andTimemust 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.