Cryptic !m_DidAwake Error in C# AddComponent

I’m learning Unity (on day 2 now). I’m spawning a ragdoll, and iterating its children in order to toss it upwards. Any child with a rigidbody has a random upwards force applied.

This works fine. The ragdoll is thrown upwards in an entertaining fashion. Next, I need to keep track of where the RagdollController component is for any given RigidBody.

So, I created a simple RagdollPiece component with a single member variable pointing to the Ragdoll Controller. I figure I can attach this component at runtime alongside the upwards force.

Here’s my code (apologies for the sloppiness):

using UnityEngine;
using System.Collections;

public class RagdollController : MonoBehaviour {

	void Start () {		
		ThrowUpwards(transform);

		//Invoke("DeleteRagdoll", 10f);
	}

	public int throwForce = 1400;

	void ThrowUpwards(Transform start)
	{
		//print("test");
		if (start.rigidbody != null)
		{
			// record this controller
			start.gameObject.AddComponent("RagdollPiece");
			
			//RagdollPiece ragdollPiece = start.GetComponent(typeof(RagdollPiece)) as RagdollPiece;
			//ragdollPiece.ragdollController = this;

			// random force direction
			float x = Random.Range(-1f, 1f);
			float y = 2;
			float z = Random.Range(-0.2f, 0.2f);

			Vector3 rand = new Vector3(x, y, z);
			rand = rand.normalized;

			start.rigidbody.AddForce(rand * throwForce);
		}
		
		foreach (Transform child in start)
		{
			ThrowUpwards(child);
		} 
	}
	

	void DeleteRagdoll()
	{
		Destroy(gameObject);
	}
}

However, as soon as I add the AddComponent line, I get this error in Unity:

The component is attached properly (and sets the RagdollController properly if I uncomment the next two lines). What’s going on with the error, though? Clearly I’m doing something wrong, but what?

Haw! This post is so old!

Old maybe, but I just started getting this today (v 2.6.1f3)

I am getting this error as well. But I get it after I have stoped the Editor from running the game. Right now it has produced 4789+ Errors with this !m_DidAwake error. Not sure what is causing it. Anyone have any ideas? I am using Unity 3.0

Anyone with info on !m_DidAwake ?

I am using Unity v3.1 on Windows 7, but I’ve seen this error on v2.6 as well.

I’m getting this too When messing around with PRO water reflections.

As will be evident from this thread, this error has been known about for a long time but we have never found a reproducing case. Any more information will always be welcome, so please file a bug report, ideally with your project attached.

I got the error after letting a slow moving AI ship go around a battlefield for about an hour and 45. The error didnt show up until that hour and 45 was up. It doesnt seem to be causing any disturbances though. I’ve seen it several times in the past, but it’s been about six months. As far as I can recall, it doesn’t show up unless I start messing with rigidbodies…

But now that I’m thinking about it, isn’t there some sort of odd effect that occurs when an object starts going very far distances? Some sort of jittering? If that’s the case, it may have nothing to do with the AI ship. It may be involved with the player jet that is SUPPOSED to go back to the spawn point if it goes out of bounds. It isn’t respawning correctly and just keeps going

and going

and going

and !m_DidAwake

Possibly caused by jittering?

!m_DidAwake was caused by EditorUtility.InstantiatePrefab for me.
For some reason InstantiatePrefab did not call awake immediately, and as I was stepping through the code it jumped to awake much later then normal.

I changed the function back to Instantiate and then it went to awake as normal, immediately after instantiation.
So I was using the object before it had called awake, so I assume it let me know the object had not awoke yet with, !m_DidAwake

-Vincent

I realize this is an old thread, but rather than start a new one I figured I would chime in here. I started getting this today as well, found this thread, and started seeing what would reproduce this.

When I had started noticing this I had only done some minor tweaks to some already elaborate code I’ve been working on, so I decided to save a copy and revert back prior to my changes. The error persisted even though I reverted back to code I knew never used to produce the !m_DidAwake. I also noticed that it only ever appeared when switching from MonoDevelop back into Unity, so I started playing with that. I quit Unity MonoDevelop and reloaded it; no error. I restored the code I had been working on; no error.

At this point I started thinking about when I first noticed it, which was after leaving my computer for some time… So I left my computer and let the screens shut off and viola! The error was back! Closed MonoDevelop Unity and the error was gone. It seems to be something to do with (I think) MonoDevelop and display shut off.

Running: Windows 7 Ultimate 64-bit

Hi, i had this too with Visual studio + Unity when the screen turn in pause mode (long time afk).
Kezei suggestion work too, relaunching Unity + Visual Studio solve the problem.

I recently upgraded from 3.5.1 to 3.5.6f4, never saw this error before now. Just fixed a problem with my meshes, then it started with the same symptoms as the original poster (This mostly happens when I was playing and then press the play button to stop.). Any information as to the reason for this error, or should a bug report be submitted?

kinda old thread but hope someone sees my new post and responds , well thats what i got
m_DidAwake Started appearing after i got Unity pro and used water4 for first time then after leaving my game and beeing afk for 10 min i came back and stoped the game then m_DidAwake spammed my console well i cleared it and from then it appears when i play and stop my game for more than 5 min BUT now it is spamming my editor before i even press play button atm i am getting 3000+ m_DidAwake in 2 sec !!! And my pc starts to go slow !!!
I have unity 3.6 pro
Windows 7 home premium 64x