コード例 #1
0
    void Awake()
    {
        pCon          = GetComponentInChildren <PlayerController>();
        rb            = GetComponent <Rigidbody>();
        groundChecker = transform.GetChild(0);
        playerStats   = GetComponent <PlayerStatsScript>();
        myControls    = new GameInputControls();
        var moveUpAction = new InputAction("MoveUp");

        moveUpAction.AddCompositeBinding("Axis").With("Positive", "<Keyboard>/w").With("Negative", "<Keyboard>/s");
    }
コード例 #2
0
    void OnEnable()
    {
        cameraLook       = GetComponentInChildren <InputSystem_CameraLook>();
        combatController = GetComponentInChildren <InputSystem_PlayerCombatController>();
        if (myControls == null)
        {
            myControls = new GameInputControls();
        }
        myControls.gameplay.Look.performed += cameraLook.OnLook;
        myControls.gameplay.Fire.performed += combatController.OnFire;

        myControls.gameplay.Fire.Enable();

        myControls.gameplay.Look.Enable();
    }
コード例 #3
0
    void EnableGameControls()
    {
        if (!playerStats)
        {
            playerStats = GetComponentInParent <PlayerStatsScript>();
        }
        if (!playerState)
        {
            playerState = GetComponentInChildren <PlayerStateScript>();
        }

        if (!rbMovement)
        {
            rbMovement = GetComponentInParent <InputSystem_RigidbodyCharacterMovement>();
        }
        if (!cameraLook)
        {
            cameraLook = GetComponentInChildren <InputSystem_CameraLook>();
        }
        if (!combatController)
        {
            combatController = GetComponent <InputSystem_PlayerCombatController>();
        }

        if (myControls == null)
        {
            myControls = new GameInputControls();
        }

        //if(myControls.gameplay.)
        bEnableGameInput = true;
        myControls.gameplay.Pause.performed             += OnGamePause;
        myControls.gameplay.Interact.performed          += OnInteractEvent;
        myControls.gameplay.CharacterMenu.performed     += OnCharMenu;
        myControls.gameplay.MoveRight.performed         += rbMovement.OnMoveRight;
        myControls.gameplay.MoveUp.performed            += rbMovement.OnMoveUp;
        myControls.gameplay.Sprint.performed            += rbMovement.OnSprint;
        myControls.gameplay.Jump.performed              += rbMovement.OnJump;
        myControls.gameplay.Fire.performed              += combatController.OnFire;
        myControls.gameplay.AltFire.performed           += cameraLook.OnLockOn;
        myControls.gameplay.AltFire.canceled            += cameraLook.OnLockOnStop;
        myControls.gameplay.SpecialAbility.performed    += rbMovement.OnSpecialAbility;
        myControls.gameplay.StyleSwitchUp.performed     += combatController.OnStyleSwitchUp;
        myControls.gameplay.StyleSwitchDown.performed   += combatController.OnStyleSwitchDown;
        myControls.gameplay.SelectWeaponOne.performed   += combatController.OnPrimaryWeaponSelect;
        myControls.gameplay.SelectWeaponTwo.performed   += combatController.OnSecondWeaponSelect;
        myControls.gameplay.SelectWeaponThree.performed += combatController.OnThirdWeaponSelect;
        myControls.gameplay.Zoom.performed              += cameraLook.OnZoom;
        myControls.gameplay.Look.performed              += cameraLook.OnLook;
        myControls.gameplay.Interact.Enable();
        myControls.gameplay.Fire.Enable();
        myControls.gameplay.Look.Enable();
        myControls.gameplay.Pause.Enable();
        myControls.gameplay.CharacterMenu.Enable();
        myControls.gameplay.AltFire.Enable();
        myControls.gameplay.SelectWeaponOne.Enable();
        myControls.gameplay.SelectWeaponTwo.Enable();
        myControls.gameplay.SelectWeaponThree.Enable();
        myControls.gameplay.SpecialAbility.Enable();
        myControls.gameplay.Sprint.Enable();
        myControls.gameplay.Jump.Enable();
        myControls.gameplay.MoveRight.Enable();
        myControls.gameplay.MoveUp.Enable();
        myControls.gameplay.StyleSwitchUp.Enable();
        myControls.gameplay.StyleSwitchDown.Enable();
        if (Cursor.lockState != CursorLockMode.Locked)
        {
            Cursor.lockState = CursorLockMode.Locked;
        }
        if (Time.timeScale <= 1)
        {
            Time.timeScale = 1;
        }
    }