Advertisement
kadyr

Untitled

Jul 31st, 2021
1,184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement