Advertisement
MrsMcLead

limit x position

Dec 6th, 2013
1,217
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import UnityEngine
  2. import System.Collections
  3.  
  4.  
  5. public class Shooter(MonoBehaviour):
  6.  
  7.     public projectile as Rigidbody
  8.  
  9.     public shotPos as Transform
  10.  
  11.     public shotForce as single = 1000.0F
  12.  
  13.     public moveSpeed as single = 10.0F
  14.  
  15.    
  16.    
  17.     private def Update():
  18.         h as single = ((Input.GetAxis('Horizontal') * Time.deltaTime) * moveSpeed)
  19.         v as single = ((Input.GetAxis('Vertical') * Time.deltaTime) * moveSpeed)
  20.        
  21.         if transform.position.x>6:
  22.             h = 0;
  23.         transform.Translate(Vector3(h, v, 0.0f))
  24.         print(transform.position.x);
  25.        
  26.         if Input.GetButtonUp('Fire1'):
  27.             shot = (Instantiate(projectile, shotPos.position, shotPos.rotation) as Rigidbody)
  28.             shot.AddForce((shotPos.forward * shotForce))
Advertisement
RAW Paste Data Copied
Advertisement