Advertisement
Guest User

Force script

a guest
Jun 21st, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public class Force : MonoBehaviour {
  2.  
  3. public GameObject Prefab;
  4.  
  5. public float power;
  6. public int objLimit;
  7. int objAdd;
  8. void Start () {
  9.  
  10. }
  11.  
  12. // Update is called once per frame
  13. void Update () {
  14. if (Input.GetButtonUp ("Jump")) {
  15. if(objAdd != objLimit){
  16. GameObject instance = Instantiate (Prefab, transform.position, transform.rotation)as GameObject;
  17. Rigidbody rb=instance.GetComponent<Rigidbody>();
  18. rb.AddForce (-transform.right*power,ForceMode.Impulse);
  19. objAdd++;
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement