title: How to spawn multiple prefab, with individual physics
body: <p>I Did apply some of the responses , most likely in the wrong way.. this is still not working with this RAYCAST. What am I doing wrong here?</p>
  <p>Want to spawn a prefab, which is a a ball, this ball is flying forward on flick finger on the screen.</p>
  <p>What I want is to spawn OnClick FEW/Multiple of this prefab.</p>
  <p>, prefab is spawning on Raycast Hit, BUT.. when I am flicking the object  EVERY prefab in the scene is moving in the same way.
  If I flick first one in to the Left, it goes there, but If now I flick second one to right, BOTH go to the RIGHT, but I would like them to work independent. Maybe this is easy fix to this but I can't find answer. (I'm planning to have up to 30/50 of this prefabs, so attaching separate scripts would be bit time consuming)</p>
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  
  public class BallScript1 : MonoBehaviour
  {
  Vector2 startPos, endPos, direction;
   float touchTimeStart, touchTimeFinish;
   public float timeInterval = 5f;
   public float throwForceInXandY = 1f;
   public float throwForceinZ = 40f;
  
  
  
  public static bool SpawnButtonAppear = true;
  public static bool thrown = false;
  public static bool moving = false;
  public static bool fly = false;
  public  bool Pressed = false;
  
  
  
  Rigidbody rb;
  public GameObject player;
  public Vector3 originalPos;
  public GameObject playerPrefab;
  
  string touched;
  
  
  void Start()
   {
       rb = GetComponent&lt;Rigidbody&gt;();
      rb.isKinematic = true;
     
  }
  
  private void OnMouseDown()
  {
      PlayerTest.clicked = true;
  }
  
  
   void Update()
   {
  
      if (Input.GetMouseButtonDown(0))
      {
          RaycastHit _hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  
          if (Physics.Raycast(ray, out _hit))
          {
               touched = _hit.collider.tag;
  
              if (touched == &quot;Player&quot;)
              {
  
                  Invoke(&quot;spawned&quot;, 0.5f);
  
              }
          }
      }
  
      if (touched == &quot;Player&quot;)
      {
          if (Input.touchCount &gt; 0 &amp;&amp; Input.GetTouch(0).phase == TouchPhase.Began)
          {
              touchTimeStart = Time.time;
              startPos = Input.GetTouch(0).position;
          }
  
  
          if (Input.touchCount &gt; 0 &amp;&amp; Input.GetTouch(0).phase == TouchPhase.Ended)
          {
  
              fly = false;
              touchTimeFinish = Time.time;
  
              endPos = Input.GetTouch(0).position;
  
              direction = startPos - endPos;
  
              rb.isKinematic = false;
              rb.AddForce(-direction.x * throwForceInXandY, -direction.y * throwForceInXandY, throwForceinZ * timeInterval);
  
              BackWall.canSpawnNow = 1;
  
          }
      }
  
     
  
  }
  
  
  
  public void spawned()
  {
      GameObject spawnedprefab = Instantiate(playerPrefab, new Vector3(originalPos.y, originalPos.x, originalPos.z), Quaternion.identity);
      Destroy(spawnedprefab, 5f);
  
  }
  </code></pre>