-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathTips_and_Tricks.txt
More file actions
67 lines (46 loc) · 2.86 KB
/
Tips_and_Tricks.txt
File metadata and controls
67 lines (46 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
*Change execution order - Edit, Project Settings, Script Execution Order*
Updates:
FixedUpdate() - Update before every physics
Update() - Updates before every frame
LateUpdate() - Updates after Update() [usually for cameras]
*Prefabs -> Collection of GameObjects and Components that are reusable throughout the game*
Game Controller -> runs game, spawns hazards, keep track of score, end game, etc.
Add tags and empty game objects in the hierarchy for organization
Import 3D Graphics - Attach a Texture to a Material, attach a Material to a 3D Object (primitive and placeholder object)
How to make a prefab
-Drag object into the prefab folder
3. Whatever changes are made to the prefab in the folder, the same changes are made to the instances of that prefab
To make similar prefabs
1. Duplicate the prefab that you want to change
2. Make changes to the duplicated prefab
Find a game object through script -> GameObject.FindObjectOfType<TypeOfGameObject>();
Change sprites on collision: Make a Sprite[] array, store sprites (such as broken blocks) into that array, and run through the sprite sheet (can animate like this too)
Snap to grid -> Edit, Snap Settings, Edit one unit size on the grid, then select all objects
****Hold command and move to snap to grid*****
-Movement by Mouse tutorial: https://www.udemy.com/unitycourse/learn/v4/t/lecture/1950096
-A Rigidbody allows the game object to have physics attributes
*Usually includes Physics Materials
*Physics Materials includes friction and bounce
Types:
-Static -> doesn’t move
-Kinematic -> doesn’t move unless you tell it to move (ie. controls)
-Dynamic -> follows physics scenarios
-Always a game object & script pair -> a script has to be a part of a game object
*ex. MusicPlayer - empty game object with a music script (can use DontDestroyOnLoad)
*ex. LevelManager - empty game object with a script that manages changes in scenes
-Camera "size" is half the height
=====================================================================================
Organization:
Scenes, Fonts, Materials (Physics, Render, etc.), Prefabs, Scripts, Sounds, Sprites
Use PlayerPrefs to store floats, ints, and strings, into the computer
=====================================================================================
Mobile:
Use Input static class to get touches
-ex: Touch myTouch = Input.GetTouch(0);
-myTouch.fingerId -> Track actions of a specific touch
-myTouch.position -> Vector2 of position of touch in screen space (pixels)
-myTouch.deltaPosition -> Takes difference of touch position between 2 frames (movement)
-myTouch.deltaTime
-myTouch.tapCount -> measure of how many taps are made in quick succession (multiple taps at once will be treated as a single finger around the screen)
-myTouch.phase = TouchPhase. Began, Canceled, Ended, Moved, Stationary
(Access all of touch array: Touch[] myTouches = Input.touches;