subere23

SpawnBallOnTouch

Jan 10th, 2018
388
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.XR.iOS;
  5.  
  6.  
  7. public class SpawnBallOnTouch : MonoBehaviour
  8. {
  9.  
  10. public GameObject spherePrefab;
  11. public float force = 5.0f;
  12.  
  13. private Rigidbody rb;
  14.  
  15.  
  16. // Update is called once per frame
  17. void Update () {
  18.  
  19. var touch = Input.GetTouch (0);
  20. if(touch.phase == TouchPhase.Began )
  21. {
  22. GameObject go = Instantiate (spherePrefab, transform.position, transform.rotation);
  23. go.GetComponent<Rigidbody>().velocity = transform.forward * force;
  24. }
  25. }
  26. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×