子弹代码

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 
 5 public class Bullet : MonoBehaviour {
 6     public float moveSpeed = 5f; 
 7     // Use this for initialization
 8     void Start () {
 9         
10     }
11     
12     // Update is called once per frame
13     void Update () {
14         transform.Translate(transform.up * moveSpeed * Time.deltaTime, Space.World); //子弹的移动
15     }
16 
17     //触发进入
18     public void OnTriggerStart2D(Collider2D col)
19     {
20         Debug.Log("触发进入");
21         print("触发进入");
22     }
23 
24 
25     //触发持续
26     public void OnTriggerEndter2D(Collider2D col)
27     {
28         print("触发持续");
29     }
30 
31     //触发结束
32     public void OnTriggerExit(Collider2D col)
33     {
34         print("触发结束");
35     }
36 }

 

你可能感兴趣的:(子弹代码)