Guest User

Untitled

a guest
Jul 21st, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Shoot : MonoBehaviour
  5. {
  6. public float speed;
  7. public Transform bullet;
  8.  
  9. // Use this for initialization
  10. void Start ()
  11. {
  12. speed = 200;
  13. }
  14.  
  15. // Update is called once per frame
  16. void Update ()
  17. {
  18. if(Input.GetKeyDown(KeyCode.Mouse0))
  19. {
  20. Transform projectile = Instantiate(bullet, transform.position, transform.rotation) as Transform;
  21. projectile.rigidbody.AddForce(transform.forward * speed);
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment