Since it's not always convenient to be using random avatars or a signed in gamers avatar (especially as the signed in gamer's avatar isn't allowed a life of its own), you may want to create an avatar in the editor and use that in the game as a NPC friend, enemy or boss. Additionally, you may want to keep randomising avatars till you find one you like, and keep that to use. This tutorial will show you exactly how to accomplish this.
The AvatarDescription Class
The AvatarDescription class stores a byte array containing 1021 entries. This array stores all the unique characteristics of an avatar, such as skin colour, weight, clothes, facial features, hair etc. The last 19 bytes of this array, appears to be a checksum, preventing you from creating your own avatars (unless of course you know how the checksum is generated.) The guys on the XNA forums are looking into determining what in the array does what. If there's an element you need, I recommend using the avatar editor on the NXE dashboard, then seeing what's changed, as per the advice of AtraX.
The Parser Script [Located Here]
This script simply runs through the supplied text, parsing it using a regular expression and outputting the second column in one of four formats. As a byte array, for hardcoding, then as newline delimited, comma separated values or XML for easy storage external to the binary, so that you can store many preset avatars and load them in from a file(s).
Step One: Run the avatar code from Tutorial One or indeed any avatar code which makes use of the AvatarDescription class.
Step Two: As soon as this code is running on your screen, hit the break all button, or use the Ctrl-Shift-Break shortcut.
Step Three: Bring up the locals window, the locals window shows you all the local variables at play which you can inspect and examine the values of. Here we are very much interested in what is stored in the avatarDescription.description. If the locals window is not already up hit Ctrl-Alt-V,L.

Step Four: Now under game->avatarDescription->description (or equivalent), highlight all entries in the description from [0] down to [1020], right click and hit copy.

Step Five: Next, load up the parser script on my site, paste into the box, and using the byte array format, and hit submit:

Step Six: This will now parse the data, and put it in a format that can be used easily in our code. Highlight and copy the results, including the { and } at each end.
Step Seven: Now back in the Visual Studio hit the stop button or press Shift-F5. Now find and replace the avatarDescription initialisation code, instead of generating a random avatar (or using a signed in gamer's avatar) we now want to use the avatar data we've obtained from the IDE, using the following line (pasting in the clipboard):
avatarDescription = new AvatarDescription(new byte[] YOURBYTEARRAYHERE );
e.g.
avatarDescription = new AvatarDescription(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, ...... 58, 45, 243, 60 } );Step Eight: The avatarDescription now is a preset avatar rather than an avatar generated on each execution of the game.
In summary, we've grabbed the desription out of the IDE, processed it and put it back into the code to ensure a permanent avatar appearance.
Complete source (Game1.cs)
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace AvatarStepOne
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
AvatarDescription avatarDescription;
AvatarRenderer avatarRenderer;
AvatarAnimation avatarCelebrateAnimation;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
Components.Add(new GamerServicesComponent(this));
}
protected override void LoadContent()
{
avatarDescription = new AvatarDescription(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, 0, 16, 0, 0, 3, 26, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 0, 8, 0, 0, 3, 37, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 0, 32, 0, 0, 3, 59, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 0, 0, 128, 0, 2, 250, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 63, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 2, 142, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 63, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 2, 110, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 63, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 215, 185, 113, 255, 55, 33, 22, 255, 235, 125, 128, 255, 114, 127, 53, 255, 55, 33, 22, 255, 197, 73, 109, 255, 55, 33, 22, 255, 101, 68, 40, 255, 101, 68, 40, 0, 0, 0, 2, 0, 0, 0, 1, 193, 200, 241, 9, 161, 156, 178, 224, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 31, 0, 3, 193, 200, 241, 9, 161, 156, 178, 224, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 96, 0, 1, 193, 200, 241, 9, 161, 156, 178, 224, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 144, 0, 1, 193, 200, 241, 9, 161, 156, 178, 224, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 60, 0, 1, 193, 200, 241, 9, 161, 156, 178, 224, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 183, 145, 254, 13, 246, 78, 178, 157, 244, 219, 52, 73, 35, 119, 60, 219, 58, 45, 243, 60 });
avatarRenderer = new AvatarRenderer(avatarDescription);
avatarCelebrateAnimation = new AvatarAnimation(AvatarAnimationPreset.Celebrate);
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
if (avatarRenderer.IsLoaded)
{
avatarCelebrateAnimation.Update(gameTime.ElapsedGameTime, true);
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
avatarRenderer.View = Matrix.CreateLookAt(new Vector3(0, 1, -3), new Vector3(0, 1, 0), new Vector3(0, 1, 0));
avatarRenderer.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, .01f, 40.0f);
avatarRenderer.Draw(avatarCelebrateAnimation.BoneTransforms, avatarCelebrateAnimation.Expression);
base.Draw(gameTime);
}
}
}