0% found this document useful (0 votes)
23 views

Copy of Unity Code Notes 1

Uploaded by

zaniuchiha12
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Copy of Unity Code Notes 1

Uploaded by

zaniuchiha12
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Start and Update Method:

The startStart is code to execute on the very first frame, and Update executes on
every frame.
Move Left and Right:
Creating a Variable :

Start and Update Method:


Start is code to execute on the very first frame, and Update executes on every frame.
Move Left and Right:
Creating a Variable :
public float keyinput;
Taking input from Keyboard :
keyinput = input.GetAxis("horizontal");
keyinput = input.GetAxis("horizontal");
*Horizontal = Left Right Arrow Keys
Providing Our Rigid Body the vector velocity in dire

public float keyinput;


Taking input from Keyboard :
public float keyinput;
keyinput = input.GetAxis("horizontal");
keyinput = input.GetAxis("horizontal");
t Arrow Ke*Horizontal = Left Right Arrow Keys
Providing Our Rigid Body the vector velocity in directions :
GetComponent<Rigidbody>().velocity = new); Vector3 (x,y,z); *V
elocity is Speed but ⁰@in a direction. keyinput = input.GetAxis("horizontal");
*To move left and right we will give keyinput into the x axis.
Jumping::
Adding an event when key is pressed :
Input.GetKeyDown(KeyCode.”KEY”);
* select any key from keyboard like for jump we can use Space as key.
Providing Our Rigid Body the vector velocity in directions :
GetComponentGetComponent<Rigidbody>().AddForce (Direction,Type); *We have to
add Direction and type of force as arguments.
*Direction to jump - > Vector3.up
*Force to Jump - > ForceMode.VelocityChange

You might also like