AddForce on Prefab has inconsistent behaviour.

I am instantiating a prefab and using AddForce via ForceMode.Impulse to make it move. Unfortunately, every once in a while (approximately 1 in 20), AddForce does not work. Here is the relavent code:

using UnityEngine;
using System;
using System.Collections;

[RequireComponent(typeof(PauseManager))]
public class PlayerConstructor : MonoBehaviour
{
	public GameObject playerPrefab;
	public GameObject planetLooperPrefab;
	
	public GameObject player;
	
	public Transform startPosition;
	public Transform impulseTarget;
	public bool planetLooper;
	
	void Awake()
	{
		player = (GameObject)Instantiate(playerPrefab);
		player.name = "Player";
		
		GetComponent<PauseManager>().toPause.Add(player.GetComponent<PauseBehaviour>());
		
		if(startPosition != null)
			player.transform.position = startPosition.position;
		
		if(startPosition != null && impulseTarget != null)
			player.rigidbody.AddForce(impulseTarget.position - startPosition.position, ForceMode.Impulse);
		
		if(planetLooper && planetLooperPrefab != null)
		{
			GameObject looper = (GameObject)Instantiate(planetLooperPrefab);
			looper.transform.parent = player.transform;
			looper.GetComponent<PlayerLooped>().player = player;
			looper.GetComponent<MessageBroadcaster>().targets[0] = gameObject;
		}
	}
}

So far in my troubleshooting I have confirmed:

  • startPosition and impulseTarget are not null.
  • AddForce does indeed get called.
  • The force being added is significant. (it is 1000 on a game object of mass 1)
  • The object is not colliding with anything (Debug.Log in OnCollisionEnter)

I have since moved that AddForce that was causing issues from ‘Awake’ to ‘FixedUpdate’. The problem seems to have disappeared.

This solution confuses me because if you check the docs on Execution Order, Awake is called before FixedUpdate and there is nothing specifying that anything in the Physics changes between this. The Rigidbody docs do specify that all physics functionality should be used within FixedUpdate, but I still don’t see why it couldn’t be used in Awake.