Instantiate and add Rigidbody force

Hey all, I’m trying to add force to a game object’s rigidbody when it’s instantiated. I’m pretty sure I’m just missing something simple here, but for some reason it’s spawned and just falls to the ground from its spawn position. Any help would be greatly appreciated! Here’s my code snippet, let me know if you need any more to diagnose the issue!

    public void ShootMe()
    {
        Vector3 playerDirection = player.forward;
        Quaternion playerRotation = player.rotation;

        Vector3 spawnPos = player.position + playerDirection * spawnDistance;
        Instantiate(item, spawnPos, playerRotation);
        item.GetComponent<Rigidbody>().AddForce(player.forward * multiplier);

        StartCoroutine(Reset());
    }

@tadmakesgames It’s because there isn’t a RigidBody attached

GameObject newItem = Instantiate(new GameObject(), spawnPos, playerRotation);
newItem.AddComponent<Rigidbody>();
newItem.GetComponent<Rigidbody>().AddForce(player.forward * multiplier);

Make sure the multiplier value is high enough to put an affect on the object. Try changing the values until you get the desired effect. And you might want to look into force modes Unity - Scripting API: ForceMode

It should be as simple as:

var spawn = Instiate(item, position, rotation);
spawn.GetComponent<RigidBody>().AddForce(200, ForceMode.Impulse);

But I’ve found that when doing addForce it can get called before the physics of an insantiated object
has been initialised. The fix is easy though.

void Spawn () {
	var spawn = Instiate(item, position, rotation);
	StartCoroutine(PhysicsLate(spawn.GetComponent<RigidBody>()));
}

IEnumerator PhysicsLate (RigidBody rb){
	yield return new WaitForSeconds(0.01f);
	rb.AddForce(200, ForceMode.Impulse);
}