Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class playerShoot : MonoBehaviour {
  5.  
  6. public GameObject spear;
  7.  
  8. public int speed = 100 ;
  9. public float fireRate = 0.5f;
  10.  
  11. private float nextShot = 0.0f;
  12. private Object bullet;
  13.  
  14.  
  15.  
  16. // Use this for initialization
  17.  
  18.  
  19. // Update is called once per frame
  20. void Update () {
  21. if (Input.GetButton("Fire1") && Time.time > nextShot) {
  22. nextShot = Time.time + fireRate;
  23.  
  24.  
  25. GameObject clone;
  26.  
  27. clone = (GameObject)Instantiate(spear, transform.position, transform.rotation);
  28.  
  29. clone.GetComponent<Rigidbody>().velocity = 35 * transform.localScale.x * clone.transform.forward;
  30.  
  31.  
  32.  
  33.  
  34.  
  35. }
  36.  
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement