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 shootcontroller : MonoBehaviour
- {
- public GameObject Bullet;
- public float Shootspace;
- public float Shootintensity;
- private float ShootCounter;
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- ShootCounter -= Time.deltaTime;
- if ((Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Q)) && ShootCounter <= 0)
- {
- ShootCounter = Shootspace;
- GameObject bl = Instantiate(Bullet, transform.position, transform.rotation);
- Rigidbody rb = bl.GetComponent<Rigidbody>();
- rb.AddForce(transform.forward * Shootintensity);
- Destroy(bl, 6.0f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement