conye – Unity2

Some reminders for myself:

  • Start function => void Start()
  • update function called repeatedly => void Update()
  • Debug.Log
  • Do while loops do{} while() checks exit condition at end
  • For each loop is written “foreach(type item in arr)”
  • string is lowercase
  • if a var is declared public, other scripts can edit it, and it shows up in the inspector!
  • Hierarchy is:  start/update set var > inspector set var > class set var
  • Private is the default access modifier
  • Access another class => 
  • Awake called before start
  • Fixed update for physics -> called regularly
  • Update times vary
  • Get time with Time.deltaTime
  • Vector3.Cross(VectorA, VectorB)
  • If I want to get a component of the thing my script is attached to. Type Mything = getComponent<Type>();
  • We can use “enabled” property to toggle components on and off
  • Can also use “active” to toggle GameObjects on and off
  • https://unity3d.com/learn/tutorials/topics/scripting/activating-gameobjects?playlist=17117
  • mult by time.deltaTime moves it in meters per second instead of meters per frame
  • Vector3.forward, Vector3.up is a shortcut
  • Input.getKey(KeyCode.UpArrow), there’s also getButton => these return true or false based on if they’re pressed or not.
  • getAxis: => [-1, 1]
  • can detect mouseclicks on gui or colliders => OnMouseDown()
  • rigidBody(addForce())
  • Destroy to destroy game objects, use it for other objects/ components that the script isn’t actually attached to, can include timed delay
  • getComponent is expensive
  • subclass example => 
  • Use instantiate to duplicate prefabs
  • helpful link for ref => https://unity3d.com/learn/tutorials/topics/scripting/instantiate?playlist=17117
  • Invoke and InvokeRepeating(func, delay, subsequentDelays)

Screenshots (one for each of the 28 lessons in the beginning scripts thing)