kadyr

Untitled

Jul 31st, 2021
1,003
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlayerController : MonoBehaviour
  6. {
  7.     public Transform riffleStartPosition; // создаем переменную которая отвечает за старт выстрела
  8.     public GameObject bullet;
  9.  
  10.     void Update()
  11.     {
  12.         if (Input.GetMouseButtonDown(0))
  13.         {
  14.             var bul = Instantiate(bullet, riffleStartPosition.position, riffleStartPosition.rotation);
  15.             bul.GetComponent<Bullet>().SetDirection(transform.forward);
  16.             bul.transform.rotation = transform.rotation;
  17.         }
  18.     }
  19. }
  20.  
RAW Paste Data