Home > Enterprise >  Unity c# transform Function
Unity c# transform Function

Time:01-04

I am new to unity I am learning to make a driving game and i am following a course from udemy, so far thigns seems to be nice but what they didnt explain is why unity takes Floating points for its transform functions such as transform.Rotate() transform.Translate(). and also how do we calculate our value for smooth motion and what data type it pretend if we do not use f with number for example (transform.Rotate(0,0,45))<- this function make the sprite rotate in z axis super fast while z=0.1f makes it smooth in in real life 0.1f is equal to what value for us humans to understand? and how it unity reads and understands it?

Tried Values as Floating and without but couldnt understand difference also want to udnerstand how unity reads it and interpret Floating values

CodePudding user response:

In C# (and some of the other programming languages), the f suffix means float.
For example, float x = 0.1f means the value of x is 0.1.
So, if you set the value of z in transform.Rotate to 0.1f, it rotates slower than z = 45.

  • Related