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