Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UnityEngine;
- public class Bullet : MonoBehaviour
- {
- private Vector3 direction;
- [SerializeField]
- private float speed;
- public void SetDirection(Vector3 dir)
- {
- direction = dir;
- }
- void Start() { }
- void Update()
- {
- transform.position += direction * Time.deltaTime * speed;
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.tag == "Player")
- {
- other.gameObject.GetComponent<PlayerController>().ChangeHealth(-20);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement