class: center, middle # Creación de Videojuegos ### Unity --- # Unity - Useful Tricks and Features * Controller Support * Particle Systems * Animations * Coroutines * Raycast * Prefabs * Layers * Render-to-Texture --- # Controller support * Controller support is very easy! * Just use Input.GetAxis, Input.GetButton etc. * Controllers should work out of the box! --- # Particle Systems * Consist of a generator and particle properties * The generator emits particles * Particles are usually simple sprites with colors * Can be used to make nice fire, smoke, etc. * Built-in system in Unity! --- # Animations * Animations in Unity use two components: - Animator - Animation Controller * Of course you also need Animation Clips * You can make your own to animate basically anything --- # Coroutines * Remember threads? * Sometimes all you want is for a function to run independently, pause for a bit and then continue * Or you need to wait for a download of some resource * Use Coroutines! They run in the main thread, and can use all Unity API functions * Alternative: IJob interface --- class: small # Raycasts * Sometimes you want to know what the user clicks * ```Camera.main.ScreenPointToRay(Input.mousePosition);``` * ```Physics.Raycast(ray, out res)``` * Returns true if you hit anything * You will get information about what you hit in ```res``` * Also works with other rays (targeting, line-of-sight calculations, etc.) --- # Prefabs * Prefabs are collections of game objects and components that you want to reuse * Assemble in Scene, drag into Assets * You can edit the Prefab separately (since Unity 2018.3) --- # Tags and Layers * You can assign Tags and Layers to game objects * Tags can be used to tell you which type of game object you have (player, enemy, etc.) * Layers are mostly used by the Camera to determine what to show * Can also be used by Raycast to ignore certain objects --- # Render-to-Texture * Usually, Cameras render what they see to the screen * You can also set up a Camera to render to a texture * And then put that texture onto a game object * Model surveillance cameras, add a minimap, mirrors, portals, etc. --- class: center, middle # Demo time ## Get the demo project on
github
--- # Some Further Notes * Use [this .gitignore](https://github.com/yawgmoth/UnityDemo2D/blob/master/.gitignore) file when working with Unity projects in git * **Be careful** with scenes: Only one person can edit a scene at the same time (git merge will most likely **not** work) * It's easiest if everyone has their own scene to develop their parts --- # From elsewhere Andres Cartín from [Tree Interactive](https://treeinteractivecr.com/) made a presentation with Unity tips and tricks for the Global Game Jam 2019. He has graciously allowed me to share it with you. .centered[ ## Watch it [here](/CI-2807/assets/unity/cartin/index.html). ]