Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class GunShooting : MonoBehaviour {
  5. public Rigidbody Bullet;
  6. public Transform ShotPosition;
  7. public float shotForce = 1000f;
  8.  
  9. // Update is called once per frame
  10. void Update ()
  11. {
  12.  
  13. if (Input.GetButtonDown ("Fire1"))
  14. {
  15. Rigidbody shot = Instantiate (Bullet, ShotPosition.position, ShotPosition.rotation) as Rigidbody;
  16. shot.AddForce (ShotPosition.forward * shotForce);
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement