BossHealth
How do I use Boss Health
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
25 |
transform.GetComponent |
1 |
29 |
collider.transform.GetComponent |
2 |
File name: BossController.cs
Copy
21 void Update () {
22 if (transform.position != targetPoint.position) {
23 transform.position = Vector3.MoveTowards (transform.position, targetPoint.position, speed * Time.deltaTime);
24 } else {
25 transform.GetComponent
26 transform.GetComponent
27 }
28 }
File name: PlayerBullet.cs
Copy
20 void OnTriggerEnter2D(Collider2D collider){
21 if(collider.CompareTag("Enemy")){
22 Instantiate (hit, transform.position, Quaternion.identity);
23 collider.transform.GetComponent
24 Destroy (gameObject);
25 }
26
27 if(collider.CompareTag("Boss")){
28 Instantiate (hit, transform.position, Quaternion.identity);
29 collider.transform.GetComponent
30 Destroy (gameObject);
31 }
32 }
Download file with original file name:BossHealth
BossHealth 119 lượt xem
Gõ tìm kiếm nhanh...