User Tools

Site Tools


unity

Unity | Build Your First 3D Game in Unity

https://www.youtube.com/watch?v=Ekfio0gfn-Y

  • [SerializeField]
  • (datatype) Transform
  • Physics.CheckSphere
  • Create new layer
  • (datatype) LayerMask
  • Get rid of friction
  • declare a variable array: GameObject[]
  • speed * Time.deltaTime
  • void OnCollisionEnter(Collision collision)
  • GetComponent<Rigidbody>()
  • UnityEngine.SceneManagement

Add coin & collect it

  • Just type in component name to get its property, like “transform.position.y”
  • set isTrigger checkbox to true under Collider component so that coin won't block player's movement
  • Remember to make coin as prefab



Add UI to display coin count

  • Canvas Scaler
  • Connect text to script
    • using UnityEngine.UI;

Add sound&music

  • assetstore.unity.com
  • Import from Package Manager
  • put audio file to audio source, put audio source to a variable (SerializeField) in playerMover script, play that variable in the script

Add another level

  • SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);

Add start screen

  • Canvas: Canvas Scaler: Scale with Screen Size
  • Match with height
  • Shift + Space to expand runtime window to fullscreen

Next: https://www.youtube.com/watch?v=dokuFmmbyaQ

unity.txt · Last modified: by admin