Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class NewShootControl : MonoBehaviour
- {
- // Start is called before the first frame update
- public int bulletSpeed = 50;
- public Camera _camera;
- public GameObject pointGun;
- public GameObject bullet;
- // Update is called once per frame
- void Update()
- {
- if (Input.GetMouseButtonDown(0))
- {
- GameObject pref = Instantiate(bullet
- , transform.position + transform.forward * 2f,
- _camera.transform.rotation) as GameObject;
- Physics.IgnoreCollision(transform.root.GetComponent<Collider>(), pref.GetComponent<Collider>());//отключение коллизий
- Rigidbody rb = pref.GetComponent<Rigidbody>();
- rb.AddForce(_camera.transform.rotation * new Vector3(0f, 0f, bulletSpeed));
- Destroy(pref, 2);
- //Debug.Log(_camera.transform.rotation * new Vector3(0f, 0f, bulletSpeed));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement