What is the difference Input.GetKeyDown And Input.GetKeyUp and what is private Var?

Updated on August 26, 2018 in  [R] Scripts
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
4 on November 13, 2016

Hello dude i am confused in what is Input.GetKeyDown and Input.GetKeyUp and what is Private Var too and what means in &&
3A.Jumping – Make A Game – Brackeys
https://www.youtube.com/watch?v=PazLGgeFkHI

Sorry bad English xD

 var rotationSpeed = 100;
 var jumpHeight = 8;
 private var isFalling = false;
 function Update () {
 var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
 rotation *= Time.deltaTime;
 GetComponent.().AddRelativeTorque (Vector3.back * rotation);
 if (Input.GetKeyDown(KeyCode.Space) && isFalling == false)
 {
 GetComponent.().velocity.y = jumpHeight;
 }
 isFalling = true;
 }
 function OnCollisionStay ()
 {
 isFalling = false;
 }
 
  • Liked by
Reply
1 on November 13, 2016

GetKeyDown gets fired when you press your key, well… Down and GetKeyUp gets fired when it goes back up. Both are called only once as where GetKey gets fired as long as the key is pressed. Private var just says that the variable is well… Private it’s the same as writing only var but for some more clear. You do however need to write public var if you want your variable to be public

Devoted
on November 14, 2016

And a public global variable can be accessed from the unity editor or ‘seen’ by other scripts, meaning it’s value can be accessed but not changed (I think).

Show more replies
  • Liked by
Reply
Cancel
0 on April 16, 2018

so nice about the disscussion i like it

come on guys i have a site is Makan Enak which have many recipes of food that you can practice it in www.menuenak21.blogspot.com. So come on guys visit Makan Enak site

  • Liked by
Reply
Cancel
0 on August 26, 2018

mantap sungguh menggoda sekali makanannya ini jadi pengen coba buat. Yuk teman-teman kunjungi situs ini yuk A1SLOTGAME

  • Liked by
Reply
Cancel