SHARE
TWEET

SpawnBallOnTouch

subere23 Jan 10th, 2018 336 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top