using System.Collections; using System.Collections.Generic; using UnityEngine; public class BulletMoving : MonoBehaviour { public GameObject parent; public DataBullet dataBullet; [SerializeField] private Rigidbody rb; private Vector3 direction = new Vector3(0f,0f,0f); private // Start is called before the first frame update void Start() { rb = parent.GetComponent(); direction = transform.position - parent.transform.position; } // Update is called once per frame void Update() { rb.velocity = direction * dataBullet.speed; } }