Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class playerShoot : MonoBehaviour {
- public GameObject spear;
- public int speed = 100 ;
- public float fireRate = 0.5f;
- private float nextShot = 0.0f;
- private Object bullet;
- // Use this for initialization
- // Update is called once per frame
- void Update () {
- if (Input.GetButton("Fire1") && Time.time > nextShot) {
- nextShot = Time.time + fireRate;
- GameObject clone;
- clone = (GameObject)Instantiate(spear, transform.position, transform.rotation);
- clone.GetComponent<Rigidbody>().velocity = 35 * transform.localScale.x * clone.transform.forward;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement