Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / AttackPlayer.cs
@Rackday Rackday on 21 Aug 2024 667 bytes Project Added
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class AttackPlayer : MonoBehaviour
  5. {
  6. [SerializeField] private GameObject bullet;
  7. [SerializeField] private float offSet;
  8. [SerializeField] private float velocity;
  9. private PlayerController player;
  10. void Start()
  11. {
  12. player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
  13. }
  14. public void Attack()
  15. {
  16. GameObject attack = Instantiate(bullet, transform.position +(transform.forward * offSet), Quaternion.identity);
  17. attack.GetComponent<Rigidbody>().velocity = transform.forward * velocity;
  18. }
  19. }