I need to instantiate a GameObject at certain intervals from an empty gameobject called spawnpoint and add force to the instantiated object. With the script that I have written the initiated gameobject spawns and seems to move along the correct vector but after traveling for like 2 centimetres it almost like hits an invisible wall and falls down, even with a force of lets say 10000. The script is attached to the empty gameobject called spawnpoint. What should I do? I’ve read many answers here concerning the same subject but none of them have helped. Here’s the code I have now:
public class BombSpawnAddForce : MonoBehaviour {
public Transform spawnPoint;
public GameObject ballPrefab;
public float delay = 0.01f;
public float force = 0.01f;
void Start ()
{
InvokeRepeating ("Spawn", delay, delay);
}
void Spawn()
{
GameObject ballInstance;
ballInstance = Instantiate (ballPrefab, spawnPoint.transform.position, spawnPoint.rotation) as GameObject;
ballInstance.rigidbody2D.AddForce(new Vector2 (3,5) * force);
}
}