Beispiel #1
0
    protected override void OnCreateModel()
    {
        data = MonsterData.GetByID(serverInfo.dataId);
        if (data == null)
        {
            Debuger.LogError("怪物数据Error null" + serverInfo.dataId);
            return;
        }
        AvatarModelData modelData = AvatarModelData.GetByID(data.modelId);

        gameObject = Res.ResourceManager.Instance.Instantiate <GameObject>(GameCommonUtils.GetResourceData(modelData.prefabName).resourcePath);

        transform     = gameObject.transform;
        transform.tag = "Monster";
        transform.gameObject.layer = 11;

        ActorMonster ap = gameObject.AddComponent <ActorMonster>();

        ap.theEntity = this;
        animator     = gameObject.GetComponent <Animator>();
        this.Actor   = ap;

        this.Motor           = gameObject.AddComponent <MotorParent>();
        this.Motor.theEntity = this;
        UpdatePosition();
        if (modelData != null && modelData.scale > 0)
        {
            gameObject.transform.localScale = new Vector3(modelData.scale, modelData.scale, modelData.scale);
            if (modelData.scaleRadius > 0 && ap.GetComponent <CharacterController>() != null)
            {
                ap.GetComponent <CharacterController>().radius = modelData.scaleRadius;
            }
        }

        animator.applyRootMotion = false;
    }