333GameStudio

Basic shooting

Apr 12th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.      var Bullet : Transform;
  2.      var Spawn : Transform;
  3.      
  4.      
  5.      function Update ()
  6.      {
  7.          if(Input.GetButtonDown("Fire1"))
  8.          {
  9.              Shot();
  10.          }
  11.      }
  12.      
  13.      function Shot()
  14.      {
  15.          var pel = Instantiate(Bullet, Spawn.position, Spawn.rotation);
  16.          pel.rigidbody.AddForce(transform.forward * 8000);
  17.          
  18.      
  19.      }
Advertisement
Add Comment
Please, Sign In to add comment