PBG2H23ABR_PBG2H23AKL_PMC_P.../Plunderblock/Assets/Scripts/ScriptsKevin/BulletMoving.cs

30 lines
628 B
C#
Raw Normal View History

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