Youtube Link
Thank You Creator who probably won't see this.
While looking at C# noticed a trend.
if a class has a property.
Lets say Input has a boolean property anyKeyDown
So basically:
Input.anyKeyDown
Note it is in Camel Notation
Input.GetKey(...)
Functions however keep the first Letter uppercase.
This is also the case with
Debug.Log(...)
Above was kind of confusing as I automatically write the first word as lowercase if I notice it uses somthing like camel notation.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
void Start(){
// Vector3 vec = new Vector3(0,0,1);
// transform.Translate(vec);
}
void Update(){
// if(Input.anyKeyDown){//Sense a key press (like switch? so only once per click)
// Debug.Log("We have sensed something");
// }
// if(Input.anyKey){//Sense a key press continuous.
// Debug.Log("Hold");
// }
// if(Input.GetKey(KeyCode.Return)){
// Debug.Log("Typed Enter");
// }else if(Input.GetKey(KeyCode.LeftArrow)){
// Debug.Log("Left Arrow");
// }else if(Input.GetKey(KeyCode.RightArrow)){
// Debug.Log("Right Arrow");
// }
//This is not optimal as if both keys are pressed it gives some form of hierarchy.
//Might be useful to bind two keys not to be pressed together or something. But how to work in order?
//Problem here if right and arrow are pressed together how to work this correctly?
// if(Input.GetKey(KeyCode.Return)){
// Debug.Log("Enter");
// }
// if(Input.GetKey(KeyCode.LeftArrow)){
// Debug.Log("Left Arrow");
// }
// if(Input.GetKey(KeyCode.RightArrow)){
// Debug.Log("Right Arrow");
// }
// if(Input.GetKey(KeyCode.Escape)){
// Debug.Log("esc");
// }
// if(Input.GetKey(KeyCode.W)){
// Debug.Log("W");
// }
// if(Input.GetKeyDown(KeyCode.Space)){
// Debug.Log("Space pressed Down");
// }
// if(Input.GetKey(KeyCode.Space)){
// Debug.Log("space");
// }
// if(Input.GetKeyUp(KeyCode.Space)){
// Debug.Log("Space released");
// }
// if(Input.GetMouseButtonDown(0)){
// Debug.Log("Left click down");
// }
// if(Input.GetMouseButton(0)){
// Debug.Log("Left click");
// }
// if(Input.GetMouseButtonUp(0)){
// Debug.Log("Left click release");
// }
// if(Input.GetMouseButtonDown(1)){
// Debug.Log("Right click down");
// }
// if(Input.GetMouseButton(1)){
// Debug.Log("Right click");
// }
// if(Input.GetMouseButtonUp(1)){
// Debug.Log("Right click release");
// }
//Unity has some hardcoded stuff
// if(Input.GetButtonDown("Jump")){
// Debug.Log("Jump pressed down");
// }
// if(Input.GetButton("Jump")){
// Debug.Log("Jump");
// }
// if(Input.GetButtonUp("Jump")){
// Debug.Log("Jump Release");
// }
// if(Input.GetButton("Horizontal")){
// // Debug.Log(Input.GetAxis("Horizontal"));
// Debug.Log(Input.GetAxisRaw("Horizontal"));
// }
}
void FixedUpdate(){
//Moved to Fixed Update because on update it flew out of existance.
// if(Input.GetButton("Horizontal")){
// Vector3 vec = new Vector3(Input.GetAxisRaw("Horizontal"), 0, 0);
// transform.Translate(vec);
// }
// if(Input.GetButton("Vertical")){
// Vector3 vec = new Vector3(0, 0, Input.GetAxisRaw("Vertical"));
// transform.Translate(vec);
// }
// if(Input.GetButton("Horizontal")){
// Vector3 vec = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
// transform.Translate(vec);
// }
// if(Input.GetButton("Vertical")){
// Vector3 vec = new Vector3(0, 0, Input.GetAxis("Vertical"));
// transform.Translate(vec);
// }
Vector3 vec = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
transform.Translate(vec);
}
}