Ejemplo n.º 1
0
    public void Init(CharacterParametersSO charSO)
    {
        parametersSO = charSO;

        agent        = GetComponent <NavMeshAgent>();
        animator     = GetComponent <Animator>();
        currentState = CharacterStates.Idle;

        mainCollider     = GetComponent <Collider>();
        ragdollColliders = GetComponentsInChildren <Collider>(true);
        rb  = GetComponent <Rigidbody>();
        rbs = GetComponentsInChildren <Rigidbody>(true);

        rigBuilder         = GetComponent <RigBuilder>();
        rigBuilder.enabled = false;

        if (parametersSO.team != 1)
        {
            SetBullet(PlayerControlHandler.instance.bulletParametersSO[0]);
        }

        GetComponentInChildren <SpriteRenderer>().color = parametersSO.team == 1 ? Color.green : Color.red;

        SetRagdol(false);
    }
Ejemplo n.º 2
0
    private Transform CreateCharacter(CharacterParametersSO charSO, Vector3 startPosition)
    {
        Transform GO = Instantiate(pf_Character);

        GO.position = startPosition;

        CharacterController characterController = GO.GetComponent <CharacterController>();

        characterController.Init(charSO);

        characterController.DieEvent += CharacterController_DieEvent;

        _cache.Add(GO);

        return(GO);
    }