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

Updated on February 3, 2019 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
  • wilwaywhit
Reply
2 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).

on January 22, 2019

If it’s public it can be changed by any other script

Show more replies
  • Liked by
Reply
Cancel