Turning









How do I use Turning
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PickupController.cs Copy
73     // Are we jumping? (Initiated with jump button and not grounded yet)
77     // Are we moving backwards (This locks the camera to not do a 180 degree spin)
81     // When did the user start walking (Used for going into trot after a while)
87     // the height we jumped from (Used to determine for how long to apply extra jump power after jumping.)
101     void Awake()
102     {
103         // PUN: automatically determine isControllable, if this GO has a PhotonView
104         PhotonView pv = this.gameObject.GetComponent();
105         if (pv != null)
106         {
107             isControllable = pv.isMine;
108
109             // The pickup demo assigns this GameObject as the PhotonPlayer.TagObject. This way, we can access this character (controller, position, etc) easily
110             if (this.AssignAsTagObject)
111             {
112                 pv.owner.TagObject = this.gameObject;
113             }
114
115             // please note: we change this setting on ANY PickupController if "DoRotate" is off. not only locally when it's "our" GameObject!
116             if (pv.observed is Transform && !DoRotate)
117             {
118                 pv.onSerializeTransformOption = OnSerializeTransform.OnlyPosition;
119             }
120         }
121
122
123         moveDirection = transform.TransformDirection(Vector3.forward);
124
125         _animation = GetComponent();
126         if (!_animation)
127             Debug.Log("The character you would like to control doesn't have animations. Moving her might look weird.");
128
129         if (!idleAnimation)
130         {
131             _animation = null;
132             Debug.Log("No idle animation found. Turning off animations.");
133         }
134         if (!walkAnimation)
135         {
136             _animation = null;
137             Debug.Log("No walk animation found. Turning off animations.");
138         }
139         if (!runAnimation)
140         {
141             _animation = null;
142             Debug.Log("No run animation found. Turning off animations.");
143         }
144         if (!jumpPoseAnimation && canJump)
145         {
146             _animation = null;
147             Debug.Log("No jump animation found and the character has canJump enabled. Turning off animations.");
148         }
149     }
File name: ThirdPersonController.cs Copy
71     // Are we jumping? (Initiated with jump button and not grounded yet)
75     // Are we moving backwards (This locks the camera to not do a 180 degree spin)
79     // When did the user start walking (Used for going into trot after a while)
85     // the height we jumped from (Used to determine for how long to apply extra jump power after jumping.)
92     void Awake()
93     {
94         moveDirection = transform.TransformDirection(Vector3.forward);
95
96         _animation = GetComponent();
97         if (!_animation)
98             Debug.Log("The character you would like to control doesn't have animations. Moving her might look weird.");
99
100         /*
101     public AnimationClip idleAnimation;
102     public AnimationClip walkAnimation;
103     public AnimationClip runAnimation;
104     public AnimationClip jumpPoseAnimation;
105         */
106         if (!idleAnimation)
107         {
108             _animation = null;
109             Debug.Log("No idle animation found. Turning off animations.");
110         }
111         if (!walkAnimation)
112         {
113             _animation = null;
114             Debug.Log("No walk animation found. Turning off animations.");
115         }
116         if (!runAnimation)
117         {
118             _animation = null;
119             Debug.Log("No run animation found. Turning off animations.");
120         }
121         if (!jumpPoseAnimation && canJump)
122         {
123             _animation = null;
124             Debug.Log("No jump animation found and the character has canJump enabled. Turning off animations.");
125         }
126
127     }
File name: Pools.cs Copy
50     public GameObject GetPoolableObject(string objName)
51     {
52         GameObject returningObj = null;
53         GameObject[] allObjects = null;
54
55         switch (objName)
56         {
57             case "p_bullet": allObjects = bulletsPlayer; break;
58             case "e_bullet": allObjects = bulletsEnemy; break;
59             case "enemy_01": allObjects = enemies_01; break;
60             case "enemy_02": allObjects = enemies_02; break;
61             case "enemy_03": allObjects = enemies_03; break;
62             case "bonus": allObjects = bonuses; break;
63         }
64
65         for (int i = 0; i < allObjects.Length; i++)
66         {
67             if (!allObjects[i].activeInHierarchy)
68             {
69                 returningObj = allObjects[i];
70             }
71         }
72
73         return returningObj;
74     }
File name: SystemScr.cs Copy
6     public static int Randomization_1(this Random rand, params int[] randBorders)
7     {
8         int r = Random.Range(0,100);
9         int returningValue = 0;
10
11         for (int i = 0; i < randBorders.Length-1; i++)
12         {
13             if (r > randBorders[i] && r < randBorders[i + 1])
14             {
15                 returningValue = i;
16                 break;
17             }
18         }
19
20         return returningValue;
21     }
File name: frmSplash.cs Copy
19         private void timer1_Tick(object sender, EventArgs e)
20         {
21             frmLogin frm = new frmLogin();
22             progressBar1.Visible = true;
23
24             this.progressBar1.Value = this.progressBar1.Value + 2;
25             if (this.progressBar1.Value == 10)
26             {
27                 label3.Text = "Reading modules..";
28             }
29             else if (this.progressBar1.Value == 20)
30             {
31                 label3.Text = "Turning on modules.";
32             }
33             else if (this.progressBar1.Value == 40)
34             {
35                 label3.Text = "Starting modules..";
36             }
37             else if (this.progressBar1.Value == 60)
38             {
39                 label3.Text = "Loading modules..";
40             }
41             else if (this.progressBar1.Value == 80)
42             {
43                 label3.Text = "Done Loading modules..";
44             }
45             else if (this.progressBar1.Value == 100)
46             {
47                 frm.Show();
48                 timer1.Enabled = false;
49                 this.Hide();
50             }
51         }

Turning 182 lượt xem

Gõ tìm kiếm nhanh...