Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Threading;
- public class Shooting : MonoBehaviour {
- public GameObject bullet; // defining objecst here
- public GameObject gun;
- public Ppauser pauzer;
- AudioSource shoots;
- public float speed = 30f;
- public float timer = 0.0f;
- public float maxtimer = 0.5f;
- void Start ()
- {
- Cursor.visible = false;
- Cursor.lockState = CursorLockMode.Locked;
- shoots = GetComponent<AudioSource>();
- }
- void FixedUpdate ()
- {
- timer += Time.deltaTime;
- if (Input.GetMouseButtonDown(0) && pauzer.paused == false && timer >= maxtimer)
- {
- shoots.Play();
- timer = 0.0f;
- GameObject shooted = Instantiate(bullet, transform.position, transform.rotation) as GameObject;
- Rigidbody rbb = shooted.GetComponent<Rigidbody>();
- rbb.AddForce(shooted.transform.forward * speed);
- }
- }
- }
Add Comment
Please, Sign In to add comment