Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Force : MonoBehaviour {
- public GameObject Prefab;
- public float power;
- public int objLimit;
- int objAdd;
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetButtonUp ("Jump")) {
- if(objAdd != objLimit){
- GameObject instance = Instantiate (Prefab, transform.position, transform.rotation)as GameObject;
- Rigidbody rb=instance.GetComponent<Rigidbody>();
- rb.AddForce (-transform.right*power,ForceMode.Impulse);
- objAdd++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement