Remote Player Models

Options
Kyros
edited January 2011 in DotNet
Hey, I have been trying to change the models of other players in the MMO Demo for a while now. I changed the CreateActor function to this for testing:
private void CreateActor(Game engine, Item actor)
    {
        // do not show local actor
        if (actor != engine.Avatar)
        {
            GameObject actorCube = GameObject.Instantiate(Resources.Load("PlayerFab")) as GameObject;
            Actor actorBehaviour = (Actor)actorCube.AddComponent(typeof(Actor));
            actorBehaviour.Initialize(actor, this.camHeight);
        }
    }

When I run it in the unity engine, it crashes when i come within viewing distance of another player. Although it works if i change the model in the prefab to a simple cube Game Object but it makes the cube retain the shape that the cylinder usually is no matter what i scale it to in the the prefab. Now when I run the game from an .exe it seems to work with the model although its a little buggy as far as its position, and the text goes. The output_log.txt seems to mostly have this error alot:
(Filename:  Line: -1)

NullReferenceException: Object reference not set to an instance of an object
  at Actor.ShowActor (Boolean show) [0x00000] in <filename unknown>:0 

  at Actor.Update () [0x00000] in <filename unknown>:0

Comments

  • Boris
    Options
    looks like something here is null:
     if (this.transform.renderer.enabled != show)
            {
                this.transform.renderer.enabled = show;
                this.actorText.transform.renderer.enabled = show;
            }
    

    Is there a way transform or transform.renderer could be null?