private void Start()
    {
        //this components we can get only after body will be spawned
        animator = GetComponentInChildren <Animator>();
        mechanim = GetComponentInChildren <MecanimWrapper>();

        //let's active gun layer on our animator
        animator.SetLayerWeight(2, 1f);
        animator.SetLayerWeight(1, 1f);

/*        mechanim.ikActive = true;*/
    }
Example #2
0
    private void OnEnable()
    {
        playerInput = GetComponent <ThirdPersonInput>();
        photonView  = GetComponent <PhotonView>();
        myTeam      = GetComponent <PlayerTeam>();
        mechanim    = GetComponentInChildren <MecanimWrapper>();

        if (photonView.IsMine && PhotonNetwork.IsConnectedAndReady)
        {
            Messenger.AddListener <Vector3>(GameEvents.AUTO_SHOOT, CheckObstacles);
            Messenger.AddListener(GameEvents.RELOAD_PRESSED, Reload);
        }
    }
Example #3
0
    void Start()
    {
        //lets find right / left hand as our body is yet spawned
        boneReferencer = GetComponentInChildren <BoneReferencer>();
        mecanim        = GetComponentInChildren <MecanimWrapper>();

        leftHand  = boneReferencer.leftHand;
        rightHand = boneReferencer.rightHand;

        //spawn gun
        SpawnGun();

        SpawnReserviour();

        //subscribe to ui
        if (phtonView.IsMine && PhotonNetwork.IsConnectedAndReady)
        {
            Messenger.AddListener <Vector3>(GameEvents.AUTO_SHOOT, RotateGun);     //this is for local player - constant rotating
            Messenger.AddListener <Vector3>(GameEvents.FIRING, GlobalRotationRPC); //this is global rotating - just rotate on start fire and end fire
            Messenger.AddListener <float>(GameEvents.RELOADING, DisableAutoRotation);

/*            Messenger.AddListener<Vector3>(GameEvents.SUPER_SHOT_PRESSED, RotateGun);*/
        }
    }
 private void Start()
 {
     mechanim = GetComponentInChildren <MecanimWrapper>();
 }
Example #5
0
    private void FixedUpdate()
    {
        if (mecanim == null)
        {
            mecanim = GetComponentInChildren <MecanimWrapper>();
        }

        Collider[] overlapColliders = Physics.OverlapSphere(transform.localPosition, groundCheckRadius, noPlayerLayerMask);
        isGrounded = overlapColliders.Length != 0 ? true : false;

        if (LeftJoystick != null && (photonView.IsMine || !PhotonNetwork.IsConnectedAndReady))
        {
            Hinput = Mathf.Clamp(LeftJoystick.input.x + Input.GetAxis("Horizontal"), -1, 1);
            Vinput = Mathf.Clamp(LeftJoystick.input.y + Input.GetAxis("Vertical"), -1, 1);

            if (JumpButton != null)
            {
                m_Jump = (Input.GetKeyDown(KeyCode.Space) || JumpButton.Pressed);
            }

            camera.MoveTo(TouchField.TouchDist.y * cameraYSpeed * Time.fixedDeltaTime * -1);

            cameraRotation     = new Vector3((transform.forward * 5 + transform.position).x, (transform.forward * 5 + transform.position).y + (camera.transform.forward * 5).y, (transform.forward * 5 + transform.position).z) + Vector3.up;
            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + Vector3.up * TouchField.TouchDist.x * rotateSpeed * Time.fixedDeltaTime);
        }
        else if (newPosition != Vector3.zero)
        {
            Hinput     = Mathf.Lerp(Hinput, newHinput, Time.fixedDeltaTime * learpSpeedf);
            Vinput     = Mathf.Lerp(Vinput, newVinput, Time.fixedDeltaTime * learpSpeedf);
            targetJump = Mathf.Lerp(targetJump, newTargetJump, Time.fixedDeltaTime * learpSpeedf);

            if (Vector3.Distance(transform.position, newPosition) > distanceToForceTP)
            {
                transform.position = Vector3.Lerp(transform.position, newPosition, Time.fixedDeltaTime * learpSpeedf);
            }
            transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(newRotation), Time.fixedDeltaTime * learpSpeedf);
        }
        if (isGrounded && mecanim != null)
        {
            // calculate camera relative direction to move:
            m_CamForward = Vector3.Scale(m_Cam.forward, new Vector3(1, 0, 1)).normalized;
            m_Move       = Vinput * transform.forward + Hinput * transform.right;
            mecanim.SetHorizontalSpeed(Hinput);
            mecanim.SetVerticalSpeed(Vinput);
            mecanim.SetJump(false);
            targetJump = -1f;
        }
        else
        {
/*            mecanim.SetHorizontalSpeed(0);
 *          mecanim.SetVerticalSpeed(0);*/
            mecanim.SetJump(true);
        }

        if (m_Move != Vector3.zero)
        {
            m_Move -= m_Move * Time.fixedDeltaTime;
        }



        Jump();

        /*mecanim.SetJump(targetJump);*/

        // pass all parameters to the character control script
        _characterController.Move(m_Move * Time.fixedDeltaTime * speed);
        m_Jump = false;
    }