Timed Destroy Self

function Awake() {
yield WaitForSeconds(3);
Destroy(gameObject);

Will this code work when attached to gameobjects that after being created, stay around for 3 seconds, and then destroy themselves?

I’m intending to use this on dead bodies that appear in my game.

You can’t yield in Awake. You can do

Destroy (gameObject, 3.0);

instead.

–Eric