using System.Collections; using System.Collections.Generic; using UnityEngine; public class AttackPlayer : MonoBehaviour { [SerializeField] private GameObject bullet; [SerializeField] private float offSet; [SerializeField] private float velocity; private PlayerController player; void Start() { player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>(); } public void Attack() { GameObject attack = Instantiate(bullet, transform.position +(transform.forward * offSet), Quaternion.identity); attack.GetComponent<Rigidbody>().velocity = transform.forward * velocity; } }