Crl + S to save the file in unity vs coded file
Things that we put in the update in cs will update things every frame
transform.Rotate(0,0,45) // this will rotate the body 45 degree to the z axis
transform.Translate(0,0,0.045f) will moves the car
[] things that are in the sq brackets are attributes
Serializefield will helps us to change speed with in the unity
Note if we change the value within our unity then that speed will overwrite the
particular speed in the cs program
edit--> projectsettings--> inputmanager (to see what are the possible input system
the unity will provide)
Input. will tells the various input methods
If we assign say (like steer spped = Input.Getaxis() --> Getaxis("Horizontal") will
gives life for A,D
Note but they work opp to which you give input to them so we add - infront in
Rotate or Translate don't put -Horizontal
but for vertical we dontneed to add -(neg) in it
(Also in the begning we should enter our player speed or enemy speed)--> Then we
should create a dummy and get Input.axis() * speed
Note these should be in the update block (we should update it every frames per
second)
Using Time.deltaTime we tell the unity engine to run how many frames per second
Then we multiply something with Time.deltaTime so that our game is frame
independent (means it knows weather the computer is fast or slow)
Example:
Slow computer Fast computer
Frames per sec 10 100
Duration of time 0.1s 0.01s
So that distance travelled will we same
1*10*0.1 = 1 1*100*0.01 = 1
we usually multiply Time.deltatime with changing axis with the user input so that
both the high end and low end pc covers same diatance
to add the graphical image to the game object first click the game object there is
a circle near the sprite renderer select it and choose your assets
To add colliders we go to components and search collider the thing which donot says
2d is actually 3d
to see weather the body is activated collider or not we can see by turning off
sprites Render(A green colour field will show)
Note: If two bodies need to collide means one object has to be rigid so that one
will move also for a rigid body there is always activated
gravity we should fix it to zero to neglect it
note: this is helpfull when we add boundaries around our game or
undestructable walls etc...
also if we add both the component rigidbody means that they both can interact with
each other
Note:
To create a map first we create a world object and there we create our map by
importing assets to unity engine
CRL + D for duplicate
CTRL + S to save
To select multiple objects we use shift + assets (like car etc) and click
(hold) and drop it the world object