Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Bullet : MonoBehaviour {
- Transform player;
- Vector3 pos_player;
- public float hit = 20;
- public float tempo;
- void Start () {
- player = GameObject.FindGameObjectWithTag ("Player").transform;
- pos_player = player.position;
- }
- // Update is called once per frame
- void Update () {
- transform.position = Vector3.MoveTowards (transform.position,pos_player,50 * Time.deltaTime);
- if(Vector3.Distance (transform.position,player.position) > 20)
- {
- //Destroy (this.gameObject);
- }
- Destroy (this.gameObject,10f);
- }
- void OnTriggerEnter(Collider other)
- {
- switch(other.tag)
- {
- case "Player":
- Destroy (this.gameObject);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement