TimeSinceShot









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

Featured Snippets


File name: CameraFollow.cs Copy
30  void Update () {
31   if (GameplayController.instance.gameInProgress) {
32    if (isFollowing) {
33     if (GameObject.FindGameObjectWithTag ("Player Bullet") != null) {
34      MoveCameraFollow ();
35     }
36    } else {
37     if (!GameplayController.instance.player.GetChild (0).transform.GetComponent ().readyToShoot) {
38      MoveCameraBackToStart ();
39      AfterShotMoveAgain ();
40      allowToMove = false;
41     } else {
42      timeSinceShot = 0;
43      allowToMove = true;
44     }
45
46    }
47
48    if (Application.platform == RuntimePlatform.Android) {
49     TouchMoveCamera ();
50    } else if (Application.platform == RuntimePlatform.WindowsEditor) {
51     MoveCamera ();
52    }
53   }
54
55  }
File name: CameraFollow.cs Copy
67  void AfterShotMoveAgain(){
68   timeSinceShot += Time.deltaTime;
69   if (timeSinceShot > 2f) {
70    if(startPosition == transform.position){
71     GameplayController.instance.player.GetChild (0).transform.GetComponent ().readyToShoot = true;
72    }
73   }
74  }
File name: GameplayController.cs Copy
198  void DistanceBetweenCannonAndBullet(){
199   GameObject[] bullet = GameObject.FindGameObjectsWithTag ("Player Bullet");
200   foreach (GameObject distanceToBullet in bullet) {
201    if (!distanceToBullet.transform.GetComponent ().isIdle) {
202     if (distanceToBullet.transform.position.x - player.position.x > distance) {
203      camera.isFollowing = true;
204      checkGameStatus = true;
205      timeSinceStartedShot = Time.time;
206      TimeSinceShot ();
207      camera.target = distanceToBullet.transform;
208     } else {
209      if(PlayerBullet() == 0){
210       camera.isFollowing = true;
211       checkGameStatus = true;
212       timeSinceStartedShot = Time.time;
213       TimeSinceShot ();
214       camera.target = distanceToBullet.transform;
215      }
216     }
217    }
218   }
219   /*if (GameObject.FindGameObjectWithTag ("Player Bullet") != null) {
220    if (!GameObject.FindGameObjectWithTag ("Player Bullet").transform.GetComponent ().isIdle) {
221     Transform distanceToBullet = GameObject.FindGameObjectWithTag ("Player Bullet").transform;
222     if (distanceToBullet.position.x - player.position.x > distance) {
223      camera.isFollowing = true;
224      checkGameStatus = true;
225      TimeSinceShot ();
226      camera.target = distanceToBullet;
227     }
228    }
229
230   }*/
231  }
File name: GameplayController.cs Copy
233  void TimeSinceShot(){
234   time += Time.deltaTime;
235   if (time > 3f) {
236    time = 0f;
237    GameObject.FindGameObjectWithTag ("Player Bullet").transform.GetComponent ().isIdle = true;
238   }
239
240  }

TimeSinceShot 118 lượt xem

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