Esempio n. 1
0
    void Awake()
    {
        join = FindObjectOfType <PlayersJoin>();

        GlobalVariables.HideCursor(true);

        StartCoroutine(CameraChange());

        playerInput     = GetComponent <PlayerInput>();
        gamepad         = Gamepad.current;
        gameObject.name = "Player " + (playerInput.playerIndex + 1);

        thirdPersonDirection = (thirdPersonPoint.position - character.headPoint.position).normalized;
        thirdPersonDistance  = Vector3.Distance(character.headPoint.position, thirdPersonPoint.position);

        if (gamepad != null)
        {
            gamepad.SetMotorSpeeds(gamepadMotors.x, gamepadMotors.y);
            gamepad.PauseHaptics();
        }

        if (teamBotCount > 0)
        {
            float angleSection = Mathf.PI * 2f / teamBotCount;
            float angle        = 0;
            for (int i = 0; i < teamBotCount; i++)
            {
                Transform botPoint = new GameObject("Bot Point " + (i + 1)).transform;
                botPoint.parent = transform;

                angle = i * angleSection;
                botPoint.localPosition = new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * (botRadius + Random.Range(-botRadiusVariation, botRadiusVariation));

                botPoints.Add(botPoint);

                Bot bot = Instantiate(botPrefab, botPoint.position, Quaternion.identity).GetComponent <Bot>();
                bot.transform.localScale *= 0.8f;
                bot.name      = "Player Bot " + (i + 1);
                bot.behavior  = Bot.BotBehavior.player;
                bot.gotoPoint = botPoint;
                bot.botIndex  = i;
            }
        }
    }
Esempio n. 2
0
    void Awake()
    {
        characterLook   = GetComponentInChildren <CharacterLook>();
        rb              = GetComponent <Rigidbody>();
        capsuleCollider = GetComponent <CapsuleCollider>();
        creator         = GetComponentInChildren <CharacterCreator>();

        join = FindObjectOfType <PlayersJoin>();

        rb.position = creator.transform.position;

        bodyOriginOrientation = transform.localRotation;
        headOriginOrientation = headPoint.localRotation;

        // Initialize the current ground check distance
        currentGroundCheckDistance = groundCheckDistance;

        initialized = true;
        OnValidate();
    }