Unity Notes
Unity Notes
Constants- UPPER_SNAKECASE
Events - PascalCase
Fields - camelCase
Functions- PascalCase
Movement controls:
If you want to set the camera to your current screen postions , then select the camera and press ctrl +
shift+F
#Note - For fixing the issue which arise due to pythogoras theorem and results in greater diagonal
distance we normalize the vector using
inputVector= inputVector.normalized;
The script inherits the properties of the object it is attached to . So you can use them to change the
properties of the object. We use "transform" to access the properties like "transform.position".
When dealing with movement logic , always multiply the postion with "Time.deltaTime". deltaTime is the
time elapsed since last frame.
Delta Time is lower for fast frame rates and higher for slow frame rates. Thus by multiplying it with the
speed , the resulting movement is consistent in both the machines having different frame rates.
(Distance = Speed * time) will remain constant as the time is changed between the machines.
You should never make fields public as it can cause unintentional changes from other classes in a
codebase.
YOu can use [SerializeField] to make a private field visible as well as editable in the unity editor.
Eg -> [SerializeField] private float x= 4f;
To make the object look at the direction it is moving, us the "transform.forward" property. assign the
direction you want the object to look at in this.
You can use "Lerp" for smoothness in transorm changes like rotation, movement, etc.
transform.forward= Vector3.slerp(intial,target,time);
##Confusion in Slerp
Add animation to the visual component and not the logical component. Always seperate the visual and
logical component of a game object.
Make the animation by simply creating animation file in the animation tab (open by window). And then
make transitions like you would in Finite State machines.
You can get component of the object to which the script is attached by using
"GetComponent<component_name>();" function.
#Note- Animator and Animation are two different components. Animation is legacy and was used a long
time ago. Animator is for more complex animations and is modern. Animation is just used for backwards
compatibility.
animator.set_data_type(String:name,value);
try avoiding using Strings for identifying things. There can many unnoticeable blunders one can make
because of that.